Scripting FTP

Posted by & filed under Uncategorized.

I recently had to add a step to a shell script that uses FTP to copy a file to a remote server.  Usually I’d use scp, secure copy, but for some reason I had to use FTP.  It had been a while since I had done this and didn’t quite remember how to do it.   It took some time to find some examples on the web, so I am going to publish one here.

ftp -n <<END_SCRIPT
user username password
cd ../remote-directory
lcd ${variable}/local-directory
put some-file.txt

An easier alternative to using this syntax would be to use the wput command.