• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2158
  • Last Modified:

FTP via SQL Server DTS and cmdshell- can't get it to work!!! 500pts.

Hi all,

I tried using the following code to automate an ftp upload:

exec master.dbo.xp_cmdshell 'cd D:\inetpub\ & ftp -s:froogle.txt "www.mysite.com " & [myFTPusername] & [myFTPpassword] '

I cannot get the DTS package to execute this ftp task- nothing fails (no errors), but when I check my ftp site, the file never gets there.

Your help is greatly appreciated,


colin
0
EllsworthAdhesives
Asked:
EllsworthAdhesives
  • 7
  • 7
  • 2
  • +3
3 Solutions
 
rboyd56Commented:
Have you tried putting this in a CMD file and calling the CMD file from a execute process task.

0
 
Kevin3NFCommented:
This would be simpler to create a one task package - ftp task and then schedule that...or am I missing a detail?
0
 
Anthony PerkinsCommented:
The following questions are now considered abandoned, please attend to them:
1 02/15/2007 500 ASP.NET 2.0, Session State (an... Open Windows OS ...
2 01/30/2007 500 ASP.NET DetailView won't hide ... Open ASP.Net Programm...
3 01/17/2007 500 MySQL help for ASP.NET.....why... Open MySQL
0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
EllsworthAdhesivesAuthor Commented:
acperkins- I have cleaned them up. Can't you send a message to my account? Or is posting on one of my questions the only way to notify me of something like this? If so, please send to my account if there is a next time.

Thanks,

colin
0
 
EllsworthAdhesivesAuthor Commented:
SQL Server 2000 FTP task only allows for incoming files from external sites, or transfer of files between directories on the same CPU (not uploads to sites, whyich is what I need). At least that's what the menu options led me to believe- that's why I am using cmdshell.
0
 
EllsworthAdhesivesAuthor Commented:
rboyd56: could you provide me an example of how I would do this (is it as easy as saving to a .txt, changing the extension to .cmd......and then, actually I don't know what I would do next (call the file).  An example would be awesome if you could show me.

Thanks
0
 
Anthony PerkinsCommented:
>>Can't you send a message to my account?<<
I am afraid not.  I am just a member of this community like yourself.
0
 
Anthony PerkinsCommented:
>>SQL Server 2000 FTP task only allows for incoming files from external sites<<
I don't believe anyone is suggesting you use the FTP Task to upload (and you are correct it cannot be done).  Rather they are suggesting you add an "Execute Process Task" which executes ftp.exe with the script.
0
 
Anthony PerkinsCommented:
P.S.  The reason the line:
exec master.dbo.xp_cmdshell 'cd D:\inetpub\ & ftp -s:froogle.txt "www.mysite.com " & [myFTPusername] & [myFTPpassword] '
Is failing is because you are attempting to change folders AND execute in the same line.  This cannot be done.
0
 
Sham HaqueSenior SAP CRM ConsultantCommented:
Create a  batch file to do what you need, then call that from xp_cmdshell:
eg.

cd D:\inetpub
ftp -s:froogle.txt "www.mysite.com " [myFTPusername] [myFTPpassword]
0
 
EllsworthAdhesivesAuthor Commented:
darnit all! I did what you suggested gbshahaq but I get nothing. I tried executing the command manually from cmd prompt and just got all the ftp options- nothing happened. I looked all over the net and the above is the only script I could find to automate an ftp upload- is there something missing, out of place, or what can I check to find out why this isn't executing?

The username and password are definately correct, as is the filename and location. I don't know what else I can do? All suggestions are greatly appreciated.

Thanks!
0
 
EllsworthAdhesivesAuthor Commented:
Oh and, acprekins- I understand about your other comment on my open questions. I just thought you were a moderator and though there must be another way of telling me that (esp. with this great new redesign of EE).

As for the automated ftp upload from SQL Server DTS via xp_cmdshell executing a bat with the above format- I still can't get it to work...
0
 
Anthony PerkinsCommented:
>>I tried executing the command manually from cmd prompt and just got all the ftp options- nothing happened.<<
That is because username and password are not valid parameters for ftp.exe.  They are usually included in the ftp script.  To see all the valid arguments you can use from the command line, use this:
FTP -?
0
 
Anthony PerkinsCommented:
Your script should look like this:
[Your FTP user name]
[Your FTP password]
put [full path name to your file]
bye

You then call it as follows:
ftp -s:[full path name to the script file] [host name]
0
 
dreadyCommented:
Maybe you could try the method described here:

http://www.nigelrivett.net/s_ftp_PutFile.html
0
 
EllsworthAdhesivesAuthor Commented:
Hi again,

Thanks for your input- I followed your suggestion, modified my script, and executed the SQL stament below, however, I still cannot get the file to go anywhere.. Do I have syntax incorrect?


exec master.dbo.xp_cmdshell  'ftp -s:D:\inetpub\ftp_upload.bat www.mysite.org'
0
 
Anthony PerkinsCommented:
What happens when you execute the following from the command line:
ftp -s:D:\inetpub\ftp_upload.bat www.mysite.org
0
 
Sham HaqueSenior SAP CRM ConsultantCommented:
you should be calling the bat file with no parameters....

1. you have a ftp script file saved as D:\inetpub\froogle.txt containing the following lines:

[Your FTP user name]
[Your FTP password]
put [full path name to your file]
bye

2. you have a batch file saved as D:\inetpub\ftp_upload.bat containing the following lines:
cd D:\inetpub
ftp -s:D:\inetpub\froogle.txt "www.mysite.org"

3. you call the batch file from the command line (to test as acperkins suggested) or from the xp_cmdshell proc.

exec master.dbo.xp_cmdshell 'D:\inetpub\ftp_upload.bat'




0
 
EllsworthAdhesivesAuthor Commented:
gbshahaq: Thank you so much- you're explaination was concise, complete, and got everything working, perfectly. Thanks to everyone else who helped out- I understand batch execution much better now and can have this run as a scheduled job on one of my SQL Servers.

Thanks again to all!! You were a great help.

-colin
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 7
  • 7
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now