Re: Expect a command with and without confirmation
- From: Glenn Jackman <glennj@xxxxxx>
- Date: 29 Mar 2007 13:22:39 GMT
At 2007-03-29 08:14AM, "Why Tea" wrote:
How to Expect this with a generic proc to handle some commands that[...]
require confirmation and some don't?
I tried this and it didn't work:
set $cmd "some command"
exp_send cmd\r
expect {
-re "Are you sure?\\r\\n> " { ## regexp didn't pick up this!!
exp_send Y\r ## is it OK to send here
exp_continue ## and back to the Expect loop?
}
> { # we are done }
timeout { # no good }
}
Try simplifying your regex:
expect {
-re {Are you sure? *$} {
exp_send "Y\r"
exp_continue
}
timeout { handle_timeout }
$prompt
}
Note the last expect pattern has no body. That can be used as a
shortcut to break out of the expect command.
--
Glenn Jackman
"You can only be young once. But you can always be immature." -- Dave Barry
.
- References:
- Expect a command with and without confirmation
- From: Why Tea
- Expect a command with and without confirmation
- Prev by Date: Re: Expect-like tool for Windows GUI?
- Next by Date: Re: Tcl event loop and threading
- Previous by thread: Expect a command with and without confirmation
- Next by thread: GiD
- Index(es):
Relevant Pages
|