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 myuser@myftp.mydomain.com
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 myuser@myftp.mydomain.com
Connecting to myftp.mydomain.com...
myuser@myftp.mydomain.com's password:
Does someone have any clue as to why I can’t get expect working as I want?
You aren’t sending a carriage return after the password.