# Expect module not working

**URL:** <https://forum.ansible.com/t/expect-module-not-working/28723>\
**Category:** Ansible Project\
**Created:** [October 4, 2018, 12:05pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723 "2018-10-04T12:05:41Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishan\_Chawla](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Krishan\_Chawla](https://forum.ansible.com/u/Krishan_Chawla)\
**Post date:** [October 4, 2018, 12:05pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/1 "2018-10-04T12:05:41Z")

</div>



---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 4, 2018, 2:50pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/2 "2018-10-04T14:50:06Z")

</div>

Can you show the output? What specific error messages are you getting?

---

<div class="post-metadata">

**Author:** ![Krishan\_Chawla](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Krishan\_Chawla](https://forum.ansible.com/u/Krishan_Chawla)\
**Post date:** [October 4, 2018, 3:20pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/3 "2018-10-04T15:20:58Z")

</div>

the output does not show any error message, but it is just taking the first three responses and not the PUM response.

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 4, 2018, 3:41pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/4 "2018-10-04T15:41:17Z")

</div>

I would suspect it is not recognizing the third prompt. Try to simplify it. You don’t need the entire phrase, just the unique part of it. Also, might try adding

echo: yes

to see if that gives you any more details.

---

<div class="post-metadata">

**Author:** ![Krishan\_Chawla](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Krishan\_Chawla](https://forum.ansible.com/u/Krishan_Chawla)\
**Post date:** [October 5, 2018, 5:59am UTC](https://forum.ansible.com/t/expect-module-not-working/28723/5 "2018-10-05T05:59:43Z")

</div>

i tried with simplified script

---

<div class="post-metadata">

**Author:** ![Krishan\_Chawla](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Krishan\_Chawla](https://forum.ansible.com/u/Krishan_Chawla)\
**Post date:** [October 5, 2018, 6:53am UTC](https://forum.ansible.com/t/expect-module-not-working/28723/6 "2018-10-05T06:53:40Z")

</div>

the problem is after the fourth response of “Y” there is extraction of files and it takes time. Would this have any problem?

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 5, 2018, 10:11am UTC](https://forum.ansible.com/t/expect-module-not-working/28723/7 "2018-10-05T10:11:19Z")

</div>

This is tough. Is there a directory that pops up when the installation is complete? You could add:

wait\_for:  
path: /peoplesoft

or just wait for a set period of time:

wait\_for: timeout=600

Or may async is better?

- name: Run bash file  
expect:  
async: 600  
poll: 10  
echo: yes  
command: ./linux/setup/psft-dpk-setup.sh  
responses:

Something like that might work?

---

<div class="post-metadata">

**Author:** ![Krishan\_Chawla](https://avatars.discourse-cdn.com/v4/letter/k/f9ae1b/32.png) [@Krishan\_Chawla](https://forum.ansible.com/u/Krishan_Chawla)\
**Post date:** [October 5, 2018, 11:30am UTC](https://forum.ansible.com/t/expect-module-not-working/28723/8 "2018-10-05T11:30:09Z")

</div>

It is showing the same exact error.

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 5, 2018, 12:06pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/9 "2018-10-05T12:06:22Z")

</div>

I think we need someone with more experience using expect. ☹  
Oracle really needs to provide a method to supply all responses either on the command line or in a file so that this can run unattended. I’ve never used the expect module. So, I’m guessing at best.

Maybe try: [Turn on debugging?](https://docs.ansible.com/ansible/2.5/user_guide/playbooks_debugger.html)

---

<div class="post-metadata">

**Author:** ![Brad2](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Brad2](https://forum.ansible.com/u/Brad2)\
**Post date:** [October 5, 2018, 12:42pm UTC](https://forum.ansible.com/t/expect-module-not-working/28723/10 "2018-10-05T12:42:09Z")

</div>

The notes in the expect module documentation state:

> The expect module is designed for simple scenarios. For more complex needs, consider the use of expect code with the shell or script modules. (An example is part of the shell module documentation)

In the shell module, there is an example of running a command with expect. Since this is more complicated and involved, maybe you should try that path?
