How to redirect data to a “getpass” like password input?
问题 I'm wring a python script for running some command. Some of those commands require user to input password, I did try to input data in their stdin, but it doesn't work, here is two simple python program represent the problem input.py import getpass print raw_input('text1:') print getpass.getpass('pass1:') print getpass.getpass('pass2:') put_data.py import subprocess import getpass def run(cmd, input=None): stdin=None if input: stdin=subprocess.PIPE p = subprocess.Popen(cmd, shell=True, stdin