ftp -n $HOST <<END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put /some/where/else/someFile.tgz
quit
END_SCRIPT
quote USER $USER
quote PASS $PASSWD
binary
put /some/where/else/someFile.tgz
quit
END_SCRIPT
But when you run the script, it reports an error like this:
someFile.tgz: Cannot create file.
How do you fix this error so that you can FTP a file to a remote host?
Solution
The problem is the file you want to transfer must reside in the current directory. In other words, you cannot have:
put /some/where/else/someFile.tgz
You must have:
put someFile.tgz
To be honest I am not sure why, but this fix solved the problem for me.
If you run a cron job, it runs in your home directory, which is the directory the command "cd" takes you to.
If the file you get on the remote host is corrupt, make sure you have the keyword "binary" right after "PASS" command.
Questions? Let me know!