# Run shell script that needs user input

**URL:** <https://forum.ansible.com/t/run-shell-script-that-needs-user-input/36085>\
**Category:** Ansible Project\
**Created:** [December 8, 2021, 10:23pm UTC](https://forum.ansible.com/t/run-shell-script-that-needs-user-input/36085 "2021-12-08T22:23:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aleksandar\_Ilic](https://avatars.discourse-cdn.com/v4/letter/a/cc9497/32.png) [@Aleksandar\_Ilic](https://forum.ansible.com/u/Aleksandar_Ilic)\
**Post date:** [December 8, 2021, 10:23pm UTC](https://forum.ansible.com/t/run-shell-script-that-needs-user-input/36085/1 "2021-12-08T22:23:10Z")

</div>

Hello everyone,

I have been trying to find a solution to run a sh script via ansible but the script requires users that run the script to enter username and password.

Is it possible to pass those vars via ansible?

Regards

---

<div class="post-metadata">

**Author:** ![Antony\_Stone](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Antony\_Stone](https://forum.ansible.com/u/Antony_Stone)\
**Post date:** [December 8, 2021, 10:28pm UTC](https://forum.ansible.com/t/run-shell-script-that-needs-user-input/36085/2 "2021-12-08T22:28:33Z")

</div>

a) not unless the script supports it

b) you might try using 'expect' to see if that can pretend to be a user at a  
keyboard.

Antony.

---

<div class="post-metadata">

**Author:** ![Mike\_Eggleston](https://avatars.discourse-cdn.com/v4/letter/m/58956e/32.png) [@Mike\_Eggleston](https://forum.ansible.com/u/Mike_Eggleston)\
**Post date:** [December 8, 2021, 10:33pm UTC](https://forum.ansible.com/t/run-shell-script-that-needs-user-input/36085/3 "2021-12-08T22:33:47Z")

</div>

You can also use the Ansible -e and use the variable is the script.

Mike
