carlregencia
carlregencia

Reputation: 15

Tcl Expect: How can you expect 2 matches in 1 line

How can you expect 2 matches in 1 line

expect "New password*" | "Retype"
send "something\r

Upvotes: 0

Views: 107

Answers (2)

Donal Fellows
Donal Fellows

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

Dinesh
Dinesh

Reputation: 16428

You can use -re flag to enable the regular expression support.

 expect -re "New password*|Retype" 
 send "something\r"

Upvotes: 1

Related Questions