Solved

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

Posted on 2007-03-29
19
2,137 Views
Last Modified: 2013-11-30
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
Comment
Question by:EllsworthAdhesives
  • 7
  • 7
  • 2
  • +3
19 Comments
 
LVL 16

Assisted Solution

by:rboyd56
rboyd56 earned 50 total points
ID: 18817281
Have you tried putting this in a CMD file and calling the CMD file from a execute process task.

0
 
LVL 21

Expert Comment

by:Kevin3NF
ID: 18818181
This would be simpler to create a one task package - ftp task and then schedule that...or am I missing a detail?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18818528
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:EllsworthAdhesives
ID: 18819068
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
 

Author Comment

by:EllsworthAdhesives
ID: 18819123
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
 

Author Comment

by:EllsworthAdhesives
ID: 18819145
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18820179
>>Can't you send a message to my account?<<
I am afraid not.  I am just a member of this community like yourself.
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18820197
>>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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18820215
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
 
LVL 18

Expert Comment

by:Sham Haque
ID: 18822065
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
 

Author Comment

by:EllsworthAdhesives
ID: 18826190
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
 

Author Comment

by:EllsworthAdhesives
ID: 18826207
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18827389
>>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
 
LVL 75

Assisted Solution

by:Anthony Perkins
Anthony Perkins earned 100 total points
ID: 18827411
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
 
LVL 11

Expert Comment

by:dready
ID: 18829876
Maybe you could try the method described here:

http://www.nigelrivett.net/s_ftp_PutFile.html
0
 

Author Comment

by:EllsworthAdhesives
ID: 18837113
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
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 18840845
What happens when you execute the following from the command line:
ftp -s:D:\inetpub\ftp_upload.bat www.mysite.org
0
 
LVL 18

Accepted Solution

by:
Sham Haque earned 350 total points
ID: 18841688
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
 

Author Comment

by:EllsworthAdhesives
ID: 18843411
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

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sql server insert 13 31
sql query to calculate avaerage 21 40
ms sql + get number in list out of total 7 29
Present Absent from working date rage 11 21
I wrote this interesting script that really help me find jobs or procedures when working in a huge environment. I could I have written it as a Procedure but then I would have to have it on each machine or have a link to a server-related search that …
Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Viewers will learn how the fundamental information of how to create a table.

803 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question