4

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.

#!/usr/bin/expect
global env
set timeout 10
spawn command that requires password
expect "^user"
send "password\r"

Please and thank you.

myusuf3
  • 35,659

1 Answers1

4

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.

Oli
  • 299,380