1

My shell script invokes a python script like this:

python take_user_input.py

The take_user_input.py script after getting invoked asks for user input, like this:

$ python take_user_input.py
Please enter your username: <expects user to enter username>
Please enter your email: <expects user to enter email>

It is not possible for me to modify the take_user_input.py script as it is part of another package.

Question: Is it possible to specify username and email in the shell script, such that it automatically takes those values after it invokes the python script?

The Wanderer
  • 3,051
  • 6
  • 29
  • 53

2 Answers2

3

Yes

printf "my_username\nmy_password\n" | python take_user_input.py
Huy Le
  • 657
  • 5
  • 17
3

You can use a here document.

python take_user_input.py << EOF
me
me@email.com
EOF
Paul Back
  • 1,269
  • 16
  • 23