Reputation: 15
How can you expect 2 matches in 1 line
expect "New password*" | "Retype"
send "something\r
Upvotes: 0
Views: 107
Reputation: 137557
The easiest way of doing this is to switch to using the other form of expect
:
expect {
"New password*" {}
"Retype" {}
}
send "something\r
The {}
can be full scripts if you need to respond differently according to what sort of things happen. The exp_continue
command is useful if you want to respond to something and keep on waiting:
expect {
"New password*" {
send "$thepassword\r"
exp_continue
}
"Retype" {
send "$thepassword\r"
exp_continue
}
"thepromptyouexpectafterwards" {}
}
send "something else\r
Upvotes: 0
Reputation: 16428
You can use -re
flag to enable the regular expression support.
expect -re "New password*|Retype"
send "something\r"
Upvotes: 1