基于预期脚本超时发生的分支

Branching based off expect script timeout occurance

是否可以在 expect 脚本中执行以下操作:

expect "phrase"
if timeout reached:
    do this
else:
    do that

参见 expect 的手册页:

   expect [[-opts] pat1 body1] ... [-opts] patn [bodyn]

         ... ...

         If the arguments to the entire expect statement require more than
         one  line,  all  the  arguments may be "braced" into one so as to
         avoid terminating each line with a backslash.  In this one  case,
         the usual Tcl substitutions will occur despite the braces.

         ... ...

         For example, the following fragment looks for a successful login.
         (Note that abort is presumed to be a procedure defined  elsewhere
         in the script.)

             expect {
                 busy               {puts busy\n ; exp_continue}
                 failed             abort
                 "invalid password" abort
                 timeout            abort
                 connected
             }