Re: How to control the loop within expect.



Hu Junfeng wrote:
Thanks.
I just use this way to solve the problem
I still want to know is any better choice for this.
Maybe Don libes should consider this function in the next version of
expect:)

He has already done this. expect has a complete programming language
for this at its beck and call (tcl ;-)

You can loop inside a call to [expect] with exp_continue like

set timeout 100
set ::customers 0

spawn ~/myshow --product books

expect \
customer {
incr ::customers
exp_continue
} thief {
puts stderr "GOTCHA"
do_call_911
} timeout {
puts "slow day"
exp_continue
} eof {
puts "shop closed"
puts "had $::customers customers today"
do_go_home
}

this will stay inside [expect] till close or a thief comes along

uwe
.



Relevant Pages