Tuesday, January 04, 2005

Automating ftp.exe sessions

ftp.exe is a command line tool that you use to connect to ftp servers. What is not very widely known about this tool is that it allows you to automate an ftp session by supplying a script which has the relevant ftp commands.

Let’s say we need to logon to the host – ftp.yourhost.com and download all the files in the dump directory on the server, we would first create a simple text file – say commands.txt which look something like this:


o ftp.yourhost.com
user username
pass password
cd dump
bin
prompt
mget *.*
close
quit


Then when using ftp.exe from command prompt, we can supply this text file as an argument to it:

ftp –s:commands.txt

that should do it!

Also see: Using FTP Batch Scripts

1 comment:

Anonymous said...

Hi, do you know of a permission setting that requires the user to be in the administrators group before the FTP puts the file on the remote server.

We moved to a 2003 server and now have problems our FTP scripting requiring a number of domain users to be included in the Administrator group or the FTP does not copy.

Thanks,

Mike