Using 'expect' to automatically send in password [duplicate] Using 'expect' to automatically send in password [duplicate] shell shell

Using 'expect' to automatically send in password [duplicate]


This expect script does the job (thanks to 'zedwood' )

#!/usr/bin/expect -fset filename [lindex $argv 0]set timeout -1spawn scp $filename myusername@192.168.1.123:/home/myusername/set pass "mypassword"expect {        password: {send "$pass\r" ; exp_continue}        eof exit}


While I agree with Sam and nik, the answer to you questions is that you didn't "hit enter":

send "mypassword\r"


Please do not even leave such scripts around that might be picked up by someone else and used elsewhere… Try public key authentication instead, it is are very easy to setup.