LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   FTP Command Line (Scripting Multiple FTP gets) (http://www.linuxquestions.org/questions/linux-software-2/ftp-command-line-scripting-multiple-ftp-gets-516421/)

Critcho 01-04-2007 09: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?

e.g.
Code:

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
http://www.reallylinux.com/docs/autoftp.shtml

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

Any help greatly appreciated!
Thanks,
Scotty.

xjlittle 01-04-2007 09:22 PM

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

070104
?

stickman 01-04-2007 10:51 PM

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

chort 01-05-2007 12:57 AM

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

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

$ 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 10:25 AM.