Linux – Send file trough FTP using command line without interactive mode

command-line-interfaceftplinux

I want to automate sending of a file through FTP using command line (on Linux). By this I mean that I want to send a file straight from the command line, without any interactive mode. I want to pass all parameters from the command line (it is on a local network for private purposes, so having password on the command line is fine for me). I know what file I want to send, and where I want to store it. My google-fu has failed me so far, because all guides concerning "command line ftp" are actually entering the interactive text interface, which is not what I want.

So how do I send a file through FTP if I do not want to enter the interactive mode and want to pass all parameters on command line?

Best Answer

If possible, install ncftp and use ncftpput and ncftpget commands for scripting uploading and downloading files.

lftp has also -c (reads FTP commands from command line parameters) and -f (reads FTP commands from a text file) options which can help you automating your FTP sessions.

If you somehow truly have to use the archaic ftp command, you can use expect (or, autoexpect).