7

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?

fzhou
  • 417
  • 1
  • 4
  • 11

1 Answers1

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

glenn jackman
  • 238,783
  • 38
  • 220
  • 352