I believe the problem is that pexpect treats all matches as regex.  You
have specified '#?' which means the # is optional, effectively making the
regex an empty string.

An empty string matches anything, so pexpect will send the response for
'#?' for everything.

You probably want:

responses:
          '#\? ': '5'
          "\[y/N\]": 'y'

I think that should like help out.

On Friday, September 4, 2015, Edgars <edgars.ma
[email protected]> wrote:

> Hi
>
> I have this task:
>
>   tasks:
>     - expect:
>         command: /path/to/bash/script.sh
>         responses:
>           '#? ': '5'
>           "[y/N]": 'y'
>
> expect module correctly responds to first prompt, but not to second. It
> responds to second prompt with '5' when it should respond with 'y'.
>
> When I enable echo=yes, I see:
>
> ...
> "#? 5"
>
> "[y/N]5"
>
> ...
>
> You can easily reproduce it with bash script and two echo/read
>
> Edgars
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/704f6fd4-b7d0-464f-a868-07ab18ba9848%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/704f6fd4-b7d0-464f-a868-07ab18ba9848%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v9A-zri4%3D9g943csUhT-65Czgm48hMyeHaLBaoFc0VchA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to