Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am new to all of this and I need to upload files via ftp from the command line.

I have this information: a url, a username, a password, a port, and the fact that I am supposed to use passive mode.

If anyone could point me in the right direction in terms of how to upload a file given this information I would be eternally grateful!

Note that I am having to do this from a script, so I need to be able to enter this information automatically.

share|improve this question
start reading ftp man pages? – NicM Dec 14 '11 at 21:47
ftp happens do be one FTP client. Others might be better suited depending on what the user wants. Simply linking to a man page isn't exactly helpful. – Daniel Beck Dec 14 '11 at 21:54

I'd highly recommend ncftp's ncftpput, very scriptable and handy for this such of things.

share|improve this answer

There's many CLI (command line) clients out there. Most common is simply ftp. You've got <host>, <port>, <username>, <pass> and "passive mode". Using ftp you should do:

ftp -p <host> <port>

-p switch means "use passive mode". Then you'll be asked about your username and password. After successful login (server let you know about that), you are able to give some commands. Type help and press "enter" to get list of commands available. You can use e.g. cd, ls, mkdir ftp commands to change working directory (on the server), list its contents and create a new directory. If before running ftp you were in the same directory as you files you want to send, you can use put or mput command to start actual transfer. First command sends one file, second multiple files using globbing (e.g. mput *pdf will send all pdf files in current directory). To get simple help about command you can use help <command> from within ftp app. I'd say that's enough for starters. For the rest use man ftp or info ftp. To end ftp session type bye. There are other ways to do that but I think this one is just elegant :).

As for the other clients, some interesting choices were pointed here, but I personally use lftp. It's just solid, good, flexible and easy to use ftp client. If you prefer more visual approach while still being under command line, you can go for mc or "Midnight Command". It's general application file manager utilizing Norton Commander paradigm, but can be also used to access ftp servers.

share|improve this answer

No problem on this one. There are lots of examples on Gist . Just go to that site and search for "FTP Script".

Here is one I found:



user ${USER} ${PASSWD}
cd /path/to/something
get $FILE

exit 0

Also, Command Line Foo is another good site, where I found this crazy awesome example of a ftp-ish file transfer:

Create a file server, listening in port 7000:

while true; do nc -l 7000 | tar -xvf -; done

Then, at client side:

tar c myfile | nc localhost 7000 ##Send file myfile to server
tar c mydir | nc localhost 7000 ## Send directory mydir to server
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.