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
  • 2,749
  • 4
  • 25
  • 51

2 Answers2

2

Yes

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

You can use a here document.

python take_user_input.py << EOF
me
me@email.com
EOF
Paul Back
  • 1,171
  • 14
  • 22