Re: Expect a command with and without confirmation



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
.



Relevant Pages

  • Re: Really need help on this one
    ... Is there a way to read the output of a particular command into ... Heres a better example using ssh. ... set timeout $timeout ... exec kill -9 $pid ...
    (comp.lang.tcl)
  • Re: dd command & reading in background
    ... ^ D,"UnixReview: Shell Corner: The dspl Korn Shell ... user input timeout, do a search on C.U.S. for the ... # 0<c<127 - job exited with this exit code ...
    (comp.unix.shell)
  • Re: How To Execute Batch File Line By Line
    ... COMMAND /C string Carries out the command specified by string, ... CMD /C Carries out the command specified by string and then terminates. ... .cmd files will NOT work on non Windows NT versions i.e. Windows 9x, ... Both .cmd and .bat files work on Windows NT versions. ...
    (microsoft.public.windowsxp.general)
  • Re: Command.Com - Sinn und Unsinn?
    ... Kompatibilität für 16-Bit-Porgs dient, dann gilt das auch ... Anforderung die ich an CMD / Command stelle! ... Ich habe seit DOS 4 "Fachwissen" um DOS - und wenn ich ...
    (microsoft.public.de.german.windowsxp.sonstiges)
  • Re: MSinfo32.exe help
    ... when i do the cmd for rd packagestore /s /q(system cant find file ... use it even though i have to use cmd to open it.this bothers me alot i defrag ... my packagestore folder didn't have any .cab files in it ... > command in case there's a problem with word wrap. ...
    (microsoft.public.windowsxp.general)