Charles Menguy
Charles Menguy

Reputation: 41458

Scripting SFTP connection with expect not working

I'm trying to connect to a SFTP server via a simple script, after looking on the web I found that expect might be something to look at, but for some reason I just can't make it work at all.

Here is the sample script I've created:

#!/usr/bin/expect

spawn sftp [email protected]
expect "password:"
send "mypassword";
interact

When I execute this it still asks me for my password for some reason, even if I did send it:

>$ ./connect-ftp.sh 
spawn sftp [email protected]
Connecting to myftp.mydomain.com...
[email protected]'s password:

Does someone have any clue as to why I can't get expect working as I want?

Upvotes: 0

Views: 2940

Answers (1)

geekosaur
geekosaur

Reputation: 61459

You aren't sending a carriage return after the password.

send "mypassword\r"

Upvotes: 2

Related Questions