Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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'm trying to set up an alias that connects to an ftp site..

so far (with the help of SO :] ) I've been able to create the alias that will connect.

I've tried adding the next command preceded by a semi-colon but it doesn't work.

What I'm looking for is a way to do:

ftp -p
[wait until the server asks for username]
[wait until server asks for p/w]


is this possible in one alias? if so, what is this called so I can learn how to do it?


share|improve this question

migrated from Sep 13 '12 at 23:58

This question came from our site for professional and enthusiast programmers.

up vote 2 down vote accepted

Actually, I don't think you'll be able to have the alias help you once you are connected. You can do some more at the command line when you log in, check the ftp man page, but I think you can specify your username with the -u option (ie. ftp -u my_username).

Once ftp starts prompting you for info (like your password) you are on your own.

A number of years ago, there was a tool called "expect" that could be used to script such interactive sessions, but there might be other (better?) ways to do this.

Update 1 .. can't find the -u option in the on line man pages ... I could have sworn this was available. Still a tool like expect should be able to help.

Update 2: have you considered using sftp instead? If you set it up correctly, you won't need to supply the password, and you can specify the user in the command line, e.g.,


also, scp will let you copy files to/from other sites, again with the username specified and passoword not needed if properly set up before.

share|improve this answer
Thanks, Yea I noticed nothing I do has an effect on the command line once I'm connected. I'm trying to write a pretty complex command in an alias to interact with my server, but the -u is helpful too! – d-_-b Sep 12 '12 at 23:57
@iight I must have gotten the -u confused from some other command, sorry. – Levon Sep 13 '12 at 0:02
If i'm not mistaken it reminds me of a mysql command line... – d-_-b Sep 13 '12 at 0:02
@iight yes, could very well be .. I had to double check to make sure it's not there. In any case, if you have the option between sftp and ftp, the secure version would be preferable. I added links to my answer – Levon Sep 13 '12 at 0:04
Thanks this is very helpful! – d-_-b Sep 13 '12 at 0:07

Have you tried:

alias doit='echo my_username > tmpfile ; echo password123 >> tmpfile ; ftp -p < tmpfile'
share|improve this answer
Sorry this didn't work, it seems to freeze the terminal...perhaps I'm writing it wrong though – d-_-b Sep 13 '12 at 0:03

You must log in to answer this question.

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