It seems that using expect_before
or expect_after
once, they are applied to any expect
following, causing unexpected timeouts.
So I wonder: How can I cancel a preceding expect_before
or expect_after
?
What I had tried so far without success (it still seems to match " "
) was:
expect_after
expect_after { }
Or did I misunderstand the concept completely?
Trying to control a shell-like program, this is what I did (roughly):
$cmd
), use expect_before $cmd
$prompt
) after the command, use expect_after $prompt
expect
to match the actual command outputHowever there are two exceptions:
$prompt
when expecting password input; thus I want to cancel the expect_after
. As the password isn't echoed, I want to cancel the expect_before
when sending the password, too.quit
command, so I want to cancel the expect_after
.I think you're misunderstanding Tcl braces. They are not special syntax, they are just a quoting mechanism -- they're like shell single quotes: no interpolation within. So expect_before { }
means you're expecting a single space, and no action is specified.
I think, to cancel an expect before, you use expect_before
with no arguments.
Use expect_before -info
to see the current status.
To ignore the sent $cmd, I think you want
expect_before -ex $cmd {exp_continue}
You need to redo this every time the cmd
variable changes.