I am trying to run an expect script, that everytime the prompt says user@blah's password, it enters the password I have the following expect script but it seem to be acting up.

Can anyone tell me what i am doing wrong? This prompt comes up multiple times over the command i run so i need it to enter the password every time, it sees user@blah's password.

global env
set timeout 10
spawn command that requires password
expect "^user"
send "password\r"

Please and thank you.

1 Answer 1


Just comparing the last bit with another example I've seen:

spawn ssh root@$ipaddr $scriptname $arg1
match_max 100000

expect "*?assword:*"
send -- "$password\r"

# send blank line (\r) to make sure we get back to gui
send -- "\r"

expect eof

Their send syntax seems slight different. And they also allow quite a liberal expect regex. The final bits might have some answers too.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.