Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Import/Export (DTS) and Replication (2000)
 FTP task to download multiple files

Author  Topic 

slugfest
Starting Member

18 Posts

Posted - 2004-10-20 : 14:06:57
I have used the FTP Task in DTS to download a single file, but how do I go about downloading multiple files from a given directory on a remote server?

Specifically, I'm trying to grab all files in a dated directory and move those to my local server.

Any help is appreciated.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-10-20 : 15:32:48
I wouldn't use an FTP task for this inside your DTS package. Instead, I would create a batch file that does the ftp commands that you need. Then call the batch file from within the DTS package using an Execute Process task.

Tara
Go to Top of Page

slugfest
Starting Member

18 Posts

Posted - 2004-10-20 : 20:48:48
T,
Can you give me a bit of direction? I'm familiar with working within DTS using the assigned tasks and using some custom scripting via SQL Server tasks, but I'm not familiar with using batch files as you described.

Thanks.
Go to Top of Page

brandonl
Yak Posting Veteran

58 Posts

Posted - 2004-10-20 : 21:29:57
quote:
Originally posted by tduggan

I wouldn't use an FTP task for this inside your DTS package.

How come? I use the batch file method myself, but am interested to know why not to use the one in DTS.

~BrandonL
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-10-20 : 21:44:20
If you go to your Windows Help file (right on the Start Menu) and look up "ftp" in the index, it will show you how the command line utility works.

Probably the easiest way to download an entire FTP directory is to save the FTP commands into a file, then use the ftp -s parameter to use that file. Copy the following and save it to a file called "ftp.txt":

open ftp.microsoft.com
user anonymous a@a.com
cd MISC
mget *.*
quit


Then run the following command in the same directory as that file:

ftp -v -n -i -s:ftp.txt

This will connect you to Microsoft's public FTP site and download all of the files in the MISC folder. Works like a charm, and if they add or delete files you don't care, the "mget" command will get any or all of them as you like.
Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2004-10-20 : 21:46:55
The DTS FTP task is not nearly as flexible or easy to use as the command line FTP is. See the example I posted. Plus, if you wanted to upload via FTP, the DTS task won't do that, but the command line will. You'd use the "put" or "mput" commands to do that.
Go to Top of Page

slugfest
Starting Member

18 Posts

Posted - 2004-10-21 : 10:06:05
Thanks for the response, Rob. The reason I am trying to do this in DTS is I need this to execute daily (on a scheduled basis). Is that something I can do with the command line utility?
Go to Top of Page

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2004-10-21 : 10:10:53
I think the general consensus is that there's nothing wrong with using DTS for this (allowing you to schedule your package to run however you want), just use an Execute Process Task to run a batch file rather than using a DTS FTP task.

Mark
Go to Top of Page

nr
SQLTeam MVY

12543 Posts

Posted - 2004-10-21 : 10:18:14
I do it from t-sql in a stored proc using the the command line exe
see
http://www.nigelrivett.net/s_ftp_PutFile.html


DTS is nothing to do with scheduling see
http://www.nigelrivett.net/BadThings.html
- it just happens that dts comes with a wizard that will create a scheduled job containing a command line dtsrun command.
The above would be a SP to schedule a call to. The other option mentioned would be a batch file which could be called via a command line call or an xp_cmdshel t-sql command.

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -