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!

Andrea
  • 1,536
d-_-b
  • 315

2 Answers2

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  username@somesite.edu

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.

Levon
  • 992
0

Have you tried:

alias doit='echo my_username > tmpfile ; echo password123 >> tmpfile ; ftp -p domain.com < tmpfile'