Re: utter newbie expect question



On May 29, 1:40 pm, Artis Gripemore <wealthe...@xxxxxxxxx> wrote:
Thanks very much! I suppose if I put a ;return after the send -- "y"
that I could break out of this, if I had more script to run after the
match on X, Y, Z?

"(X, Y, Z" {send -- "y" ;return}

Otherwise, it would continue with the next expect statement anyway,
once it timed out, correct?

Thanks again!

On May 29, 1:11 pm, Mark Janssen <mpc.jans...@xxxxxxxxx> wrote:

On May 29, 5:43 pm, Artis Gripemore <wealthe...@xxxxxxxxx> wrote:

Let me start by declaring that had I access to the Exploring book, I
would not be here posting this, I'd be figuring it out for myself and
leaving you to more interesting problems. Thanks for your patience
and any help you can offer.

My problem is that the application I want to control could generate,
at one point in its execution, any number (from 0 to 1000) "Press
<Space> to Continue" prompts, and I cannot for the life of me figure
out how to write an expect script that will deal with this. I need it
to send " " when this prompt appears, then check to see if it gets
that prompt again before it moves on, until it no longer gets that
prompt.

So it looks like this:

expect "(A, B, C"
send -- "c"
# at this point, we can get any number of "Press <Space>" prompts, to
which we need to send " " after capturing the response each time.
expect "(X, Y, Z"
send -- "y"
etc.

Thanks!

Something like:

expect {
"<Space> to Continue" {send " " ; exp_continue}
"(X, Y, Z" {send -- "y"}

}

Should do the trick. This will wait for either "(X, Y, Z" and send yes
or wait for the <Space> line and send a space in response and then
wait for either a <Space> line or a X, Y, Z line again.

Mark- Hide quoted text -

- Show quoted text -

Actually the way the script is written the first time you send "y" you
will
leave the script no return needed. You will only do the send once. By
default expect
does not loop unless you have exp_continue.

Carl

.



Relevant Pages

  • Re: Logon password script
    ... > must be changed the first time the system is logged into. ... Are you sure you need to script this? ... Administrator account, there is already built-in support for this password ... change prompt, whether you're using unattend.txt or sysprep.inf. ...
    (microsoft.public.win2000.cmdprompt.admin)
  • behavioral change of "read" builtin for sh on 8-CURRENT
    ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
    (freebsd-current)
  • behavioral change of "read" builtin for sh on 8-CURRENT
    ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
    (freebsd-questions)
  • Re: behavioral change of "read" builtin for sh on 8-CURRENT
    ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
    (freebsd-current)
  • Re: behavioral change of "read" builtin for sh on 8-CURRENT
    ... This script waits for terminal input for each of the above variables (INT, ... On 8-CURRENT if I hit Enter with no input at the prompt the system seems to ... recognize the newline as input and continues to sit there until I hit Enter ... Enter network interface: ...
    (freebsd-questions)