-   Linux - Software (
-   -   FTP Command Line (Scripting Multiple FTP gets) (

Critcho 01-04-2007 08:05 PM

FTP Command Line (Scripting Multiple FTP gets)
Is it possible to automate FTP Gets via command line use of FTP and a script?


Today="`date +%y%m%d`"
FTP remote.ip.address.1 user=UserName pwd=PassWord get remoteFile Site.1.LocalFile.$Today
FTP remote.ip.address.2 user=UserName pwd=PassWord get remoteFile Site.2.LocalFile.$Today
FTP remote.ip.address.3 user=UserName pwd=PassWord get remoteFile Site.3.LocalFile.$Today
FTP remote.ip.address.4 user=UserName pwd=PassWord get remoteFile Site.4.LocalFile.$Today

The other option is to pass a script file to the FTP program, as per

but this didn't appear to work for me either, the username and password were not accepted.

Any help greatly appreciated!

xjlittle 01-04-2007 08:22 PM

It's possible. Just to make sure of something is your date format in the form of


stickman 01-04-2007 09:51 PM

You could use curl or lftp. Both of which script pretty well.

chort 01-04-2007 11:57 PM

It depends what the default FTP client is for your distribution. For instance, OpenBSD's ftp client allows for:

$ ftp -o Site.1.LocalFile.${Today} ftp://user:password@host/remoteFile
To find out whether your FTP client supports it, type

$ man ftp
and read the SYNOPSIS section (at least).

If the default FTP client isn't sufficient, there are some extremely flexible and powerful file retrievers such as curl and wget that can easily do what you describe (and a lot more).

All times are GMT -5. The time now is 06:43 AM.