Re: tcl/expect hang
- From: Bezoar <cwjolly@xxxxxxxxx>
- Date: 7 May 2007 07:26:09 -0700
On May 6, 9:20 pm, kbuzz3...@xxxxxxxxx wrote:
On May 4, 7:04 pm, Bezoar <cwjo...@xxxxxxxxx> wrote:
On May 4, 1:05 pm, kbuzz3...@xxxxxxxxx wrote:
Hello,
I seem to be having a problem where my expect scripts seem to hang
sometimes. If I press 'enter' it will then continue to run the
script. I am not entirely positive but I believe it is related to the
sleep command. It does not happen consistently but when it does
happen it seems to happen in bunches. If it does happen due to sleep
it tends be ones that last a minute or more.
I have seen it happen in a couple of different scripts but the code
mostly looks something like:
while {$a < $b} {
send_user "*************\n"
send "router command \n"
expect {
"certain response" {
# parse expect_out buffer for results
}
timeout {
# quit script
}
}
send_user "parsed info\n"
inrc b
sleep 120
}
thank you in advance,
Matt
oops just saw your error you end all your send sequences with \n they
should be \r
so
send "router command\n" should be
send "router command \r"
Carl
Carl,
Just re-reading your post and you wrote "...saw your error...." Are
you saying that you think my problem is directly related to "\n" vs.
"\r"? Or are you just saying that you think that "\r" is a better
choice?
thanks,
Matt
I just say this because usually \r works all the time. If you've used
\n and it works then
thats good enough. I also have an idea of another way to implement
the sleep and that is
to use expect itself to do the sleep. See code below. You can also
put in an eof handler to
detect if the spawned process dies. See if this helps and let us know
if you have solved your
problem.
Carl
#!/opt/usr/bin/tclsh8.5
package require Expect
spawn /bin/sh
set timeout 3
expect {
"\#" {
puts "got prompt"
}
timeout {
puts "timeout"
}
}
# sleep 120 seconds
set timeout 120
set start [clock seconds ]
expect {
timeout {
set end [clock seconds ]
puts "slept for [ expr $end - $start ] sec "
}
}
.
- Follow-Ups:
- Re: tcl/expect hang
- From: kbuzz3400
- Re: tcl/expect hang
- References:
- tcl/expect hang
- From: kbuzz3400
- Re: tcl/expect hang
- From: Bezoar
- Re: tcl/expect hang
- From: kbuzz3400
- tcl/expect hang
- Prev by Date: Re: join strips backslash - feature or bug?
- Next by Date: How to implement the twirl sequence?
- Previous by thread: Re: tcl/expect hang
- Next by thread: Re: tcl/expect hang
- Index(es):
Relevant Pages
|