0

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 domain.com
[wait until the server asks for username]
my_username
[wait until server asks for p/w]
password123

etc...

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

Thanks!

2 Answers 2

2

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 somesite.edu -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.,

  sftp  [email protected]

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.

4
  • 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, 2012 at 23:57
  • @iight I must have gotten the -u confused from some other command, sorry.
    – Levon
    Sep 13, 2012 at 0:02
  • If i'm not mistaken it reminds me of a mysql command line...
    – d-_-b
    Sep 13, 2012 at 0:02
  • 1
    @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, 2012 at 0:04
0

Have you tried:

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

You must log in to answer this question.

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