Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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.

share|improve this answer
    
will it run for multiple password entries? –  myusuf3 Dec 21 '10 at 15:53
    
it won't I need something that will expect multiple password prompts. –  myusuf3 Dec 21 '10 at 16:02
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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