I have a expect script that need to fail when certain any of the expect condition is not meet. For example:
expect "Hello World"
If the expect script does not find "Hello World" in certain amount of time, it should fail. According to expect manual, I can add a condition timeout
in the expect, but I have many expect
statements in the script and I don't want to add a timeout for all of them. Is there a better way to do it?
By default, the expect timeout is 10 seconds. If you don't enter anything for the expect command, it times out in 20 seconds.
close would close the connection to the other process, so in sense acting as the reverse of expect eof . Again, your script could continue after this. Using close just before exiting the script doesn't do much, as an exit will also implicitly close .
The command exp_continue allows expect itself to continue executing rather than returning as it normally would. By default exp_continue resets the timeout timer. The -continue_timer flag prevents timer from being restarted. (See expect for more information.)
Expect is an extension to the Tcl scripting language written by Don Libes. The program automates interactions with programs that expose a text terminal interface. Expect, originally written in 1990 for the Unix platform, has since become available for Microsoft Windows and other systems.
expect_after {
timeout {
puts "a default timeout clause for all subsequent expect commands"
}
}
Subsequent expect commands can still provide their own timeout
clauses that will take precedence over the above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With