# How to pass different executable files in ansible / pass run the script using source and expect?

**URL:** <https://forum.ansible.com/t/how-to-pass-different-executable-files-in-ansible-pass-run-the-script-using-source-and-expect/28373>\
**Category:** Ansible Project\
**Tags:** ubuntu\
**Created:** [August 20, 2018, 6:15pm UTC](https://forum.ansible.com/t/how-to-pass-different-executable-files-in-ansible-pass-run-the-script-using-source-and-expect/28373 "2018-08-20T18:15:27Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Swathi\_Cutie](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@Swathi\_Cutie](https://forum.ansible.com/u/Swathi_Cutie)\
**Post date:** [August 20, 2018, 6:15pm UTC](https://forum.ansible.com/t/how-to-pass-different-executable-files-in-ansible-pass-run-the-script-using-source-and-expect/28373/1 "2018-08-20T18:15:27Z")

</div>

I am trying to pass a prompt y in ansible when it executes command.  
When i do manually on server it asks for a prompt.

The issue is for command to run i need to pass the executable /bin/bash  
_command: `source /etc/profile.d/tableau_server.sh && tsm pending-changes apply`_ for expect command to run i need to pass /usr/bin/expect .

My question, how can i pass 2 executable in ansible such that for command it uses /bin/bash and for expect prompt it should use /usr/bin/expect and the error is because i am using source, what is an alternative i can use?

Update: I dont know why but i am not able to pass --ignore-prompt , It gives an error

ubuntu@ip-xx-xxx-xx-xx:~$ tsm pending-changes apply --ignore-prompt  
Unrecognized option: --ignore-prompt

Please help me with a solution!

ubuntu@ip-xx-xxx-xx-xx:~$ tsm pending-changes apply  
This operation will perform a server restart. Are you sure you wish to continue?  
(y/n):

My ansible script:

shell: |  
source /etc/profile.d/tableau\_server.sh && tsm pending-changes apply  
expect “This operation will perform a server restart. Are you sure you wish to continue?\n(y/n):”  
send “y\n”  
exit 0  
args:  
executable: /usr/bin/expect  
args:  
executable: /bin/bash/expect  
when: inventory\_hostname == “xx.xxx.xx.xx”

ERROR:

changed: [xx.xxx.xxx.xx] =\> {  
“changed”: true,  
“cmd”: “source /etc/profile.d/tableau\_server.sh && tsm pending-changes apply\n expect "This operation will perform a server restart. Are you sure you wish to continue?\n(y/n):"\n send "y\n"\n exit 0”,  
“delta”: “0:00:00.034824”,  
“end”: “2018-08-20 17:29:41.457700”,  
“invocation”: {  
“module\_args”: {  
“\_raw\_params”: “source /etc/profile.d/tableau\_server.sh && tsm pending-changes apply\n expect "This operation will perform a server restart. Are you sure you wish to continue?\n(y/n):"\n send "y\n"\n exit 0”,  
“\_uses\_shell”: true,  
“argv”: null,  
“chdir”: null,  
“creates”: null,  
“executable”: “/usr/bin/expect”,  
“removes”: null,  
“stdin”: null,  
“warn”: true  
}  
},  
“rc”: 0,  
“start”: “2018-08-20 17:29:41.422876”,  
“stderr”: “wrong # args: should be "source ?-encoding name? fileName"\n while executing\n"source /etc/profile.d/tableau\_server.sh && tsm pending-changes apply"”,  
“stderr\_lines”: [  
“wrong # args: should be "source ?-encoding name? fileName"”,  
" while executing",  
“"source /etc/profile.d/tableau\_server.sh && tsm pending-changes apply"”  
],  
“stdout”: “”,  
“stdout\_lines”:

---

<div class="post-metadata">

**Author:** ![Sakthivel\_G](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Sakthivel\_G](https://forum.ansible.com/u/Sakthivel_G)\
**Post date:** [August 20, 2018, 6:36pm UTC](https://forum.ansible.com/t/how-to-pass-different-executable-files-in-ansible-pass-run-the-script-using-source-and-expect/28373/2 "2018-08-20T18:36:36Z")

</div>

Echo “y” | tsm pending-changes apply

Try this
