Despite its being a horrid, outdated, NAT-unfriendly, and deeply insecure protocol, FTP is still a fact of everyday life. The normal (BSD derived) command-line ftp client isn't immediately amenable to automation, but both it and some of its more modern command-line replacements can still be used successfully from scripts, given a little shell magic.
An equivalent way (which has no real advantage over the above way, as far as I can tell) is available to
ftp -i -n otherhost << EOF user myname mypassword mput foo bar # put normal ftp comamnds here # -i for "don't prompt before filetransfers" # -n for "don't ask for user/password" EOF
If you only need to download files from a remote machine using ftp, you can also use the GNU
echo " user myname mypassword mput foo bar # put normal ftp commands here " | ftp -i -n otherhost # -i for "don't prompt before filetransfers" # -n for "don't ask for user/password"
wgetprogram. Wget is available for download from its homepage.
Lastly, and perhaps the easiest solution, is to use the automation-friendly tools that are part of the
wget ftp://myname:mypassword@otherhost/foo # download "foo" from "otherhost"
ncftpsuite. Chief (for our purposes) among these are
You can get
ncftpput -u myname -p mypassword otherhost . foo # upload files ncftpget -u myname -p mypassword otherhost . bar # download files
ncftp(it's free, and open source) from its homepage at http://www.ncftpd.com/ncftp