Reputation: 2873
I have something like this.
expect
"hi" { send "You said hi\n" }
"hello" { send "Hello yourself\n" }
"hi" { send "2nd time you said hi\n" }
The scenario is I will get a initial response 'hi', then 'hello', then 'hi' again. The second time I get a response of 'hi', I want to send a different string.
Thanks.
Upvotes: 0
Views: 916
Reputation: 43097
You should use a list and iterate...
set responses {{You said hi} {2nd time you said hi}}
set idx 0
while {$idx < [llength $responses]} {
expect {
"hi" { send [lindex $responses $idx]\n; incr idx }
"hello" { send "Hello yourself\n" }
}
}
Upvotes: 3