Assume this code as a simple Python code which can get username and password:
from getpass import getpass
user = getpass(" enter username :")
pass = getpass(" enter password ")
print("user = ", user)
print("pass = ", pass)
in addition, suppose that we have a file named input which contains:
myusername
mypassword
I want to send this file as input for the python code in bash:
but this instruction doesn't work:
python3 get_user_pass.py < input
this is because of using getpass function, and if we use input instead of getpass, it will work correctly. How we can send an input file from bash to our python code which uses getpass?