I'm trying to get a wait script to work, and when I use the -re flag (to call a regular expression), the 'timeout' keyword doesn't seem to work anymore. When the following script is executed, I get the message "timeout in step 1", then "initial step 2", and then it expires, but DOES NOT print the "timeout in step 2". I just get a new invitation.
Ideas?
#!/usr/bin/expect -- spawn $env(SHELL) match_max 100000 set timeout 2 send "echo This will print timed out\r" expect { timeout { puts "timed out at step 1" } "foo " { puts "it said foo at step 1"} } puts "Starting test two\r" send "echo This will not print timed out\r" expect -re { timeout { puts "timed out at step 2" ; exit } "foo " { puts "it said foo at step 2"} }
source share