Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

default timeout handler for expect script

Tags:

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?

like image 757
fzhou Avatar asked Nov 20 '09 23:11

fzhou


People also ask

What is timeout in expect script?

By default, the expect timeout is 10 seconds. If you don't enter anything for the expect command, it times out in 20 seconds.

How do you end an expect script?

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 .

What is Exp_continue in expect?

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.)

What is expect in Tcl?

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.


1 Answers

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.

like image 116
glenn jackman Avatar answered Nov 15 '22 05:11

glenn jackman