The wait does not work with the '-re' flag while waiting for the script

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"} } 
0
source share
3 answers
 Figured it out: expect { timeout { puts "timed out at step 2" ; exit } -re "foo " { puts "it said foo at step 2"} } 
+2
source

Yes, the "-re" flag, as it appears in your question, applies to every template of the expect command. Thus, the timeout pattern becomes the "-re timeout", losing its feature.

+2
source

In addition, the exp_internal 1 command is very valuable as a debugging tool.

+2
source

Source: https://habr.com/ru/post/1400840/


All Articles