2

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?

2
  • What OS? What FTP program? Mar 23, 2012 at 11:34
  • @TimBrigham: The linux tag indicates the OS, and since it's easy to install additional tools on any Linux....
    – Sven
    Mar 23, 2012 at 11:37

3 Answers 3

4

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).

2
  • Thanks, ncftpput -u user -p pass host remote-dir local-file works great.
    – MiKy
    Mar 23, 2012 at 11:40
  • Great. Have a nice weekend! :) Mar 23, 2012 at 11:41
0

lftp?

$ yum info lftp
Loaded plugins: priorities, ps
Available Packages
Name        : lftp
Arch        : i686
Version     : 4.0.9
Release     : 1.el6
Size        : 735 k
Repo        : base
Summary     : A sophisticated file transfer program
URL         : http://lftp.yar.ru/
License     : GPLv3+
Description : LFTP is a sophisticated ftp/http file transfer program. Like bash, it has job
            : control and uses the readline library for input. It has bookmarks, built-in
            : mirroring, and can transfer several files in parallel. It is designed with
            : reliability in mind.

The man page is here: http://lftp.yar.ru/lftp-man.html

0

Install ncftp and use the utitilies ncftpput and ncftpget.

1
  • Huh. For some reason, I had thought ncftp had been deprecated in favor of lftp.
    – cjc
    Mar 23, 2012 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .