I\'m using subprocess to run a script from within python. I tried this
option 1
password = getpass.getpass()
from subprocess import Popen, PIPE, che
You should be passing the password as a value to the communicate() function instead of stdin.write(), like so:
from getpass import getpass
from subprocess import Popen, PIPE
password = getpass("Please enter your password: ")
proc = Popen("command option1 option2".split(), stdin=PIPE, stdout=PIPE)
# Popen only accepts byte-arrays so you must encode the string
proc.communicate(password.encode())