# Question about using the expect module

**URL:** <https://forum.ansible.com/t/question-about-using-the-expect-module/21753>\
**Category:** Ansible Project\
**Created:** [June 13, 2016, 4:28pm UTC](https://forum.ansible.com/t/question-about-using-the-expect-module/21753 "2016-06-13T16:28:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sher\_Chowdhury](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Sher\_Chowdhury](https://forum.ansible.com/u/Sher_Chowdhury)\
**Post date:** [June 13, 2016, 4:28pm UTC](https://forum.ansible.com/t/question-about-using-the-expect-module/21753/1 "2016-06-13T16:28:40Z")

</div>

I have an interactive command that prompts me enter a series of letters, b, d, and y. I was wondering if it is possible to run something like this:

```auto
- expect:
    command: /path/to/custom/command
    responses:
        - b
        - d
        - y

```

```auto
I don't need to do any regex matching, I just need to pass these letters in.

```

```auto
Although I would like to do regex matching if that is possible with my version of ansible, by the way, my verion of ansible is:

```

```auto
$ ansible --version
ansible 2.0.2.0
  config file = /etc/ansible/ansible.cfg
  configured module search path = Default w/o overrides

```

```auto
Thanks 
Sher

```

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [June 13, 2016, 4:57pm UTC](https://forum.ansible.com/t/question-about-using-the-expect-module/21753/2 "2016-06-13T16:57:34Z")

</div>

Expect works off of text to expect and a string to send. I tend to think of them as questions and answers.

You are required to provide both. At minimum I guess you could do something like:

- expect:  
command: /path/to/custom/command  
responses:  
“.\*”:
- b
- d
- y

That will answer with those letters, in order, based on any match.

---

<div class="post-metadata">

**Author:** ![Sher\_Chowdhury](https://avatars.discourse-cdn.com/v4/letter/s/7feea3/32.png) [@Sher\_Chowdhury](https://forum.ansible.com/u/Sher_Chowdhury)\
**Post date:** [June 14, 2016, 10:13am UTC](https://forum.ansible.com/t/question-about-using-the-expect-module/21753/3 "2016-06-14T10:13:00Z")

</div>

Hi Matt,

That didn’t work for me because I am using an older version of ansible, and I think what you described is for version 2.1+

However your suggestion made me realize that my understanding of how the expect module works was fundamentally wrong to begin with. I now figured out what I needed to do. In my case I’m doing an unattended (silent) upgrade of confluence, and I am using:

- expect:  
command: /tmp/atlassian-confluence-5.10.0-x64.bin  
responses:  
“This will install Confluence”: o  
“Upgrade an existing Confluence installation”: ‘3’  
“Existing installation directory”: /opt/atlassian/confluence  
“Back up Confluence home”: n  
“List of modifications made within Confluence directories.”: ’ ’  
“Do you want to proceed”: u  
timeout: 300

I now realize that “responses” operates a bit like a case statement, whereas I thought it was working as a dumb sequence of inputs.

Thank you for your help.

Kind regards,  
Sher
