python subprocess.popen - pass passwords securely

2019-08-26 15:26发布

I did not find a direct answer to this question, so, asking it in this forum. My question is this - I am using python 2.6.6 version, and using subprocess.popen command to call into a script with some arguments. Some of the arguments are passwords. When I directly use this:

args = shlex.split(cmd)
f = open("a.txt", "a+");
proc = subprocess.Popen(args, stderr=f, stdout=f)
proc.communicate()
retcode = proc.returncode

The command gets executed fine, but I see that ps -ef shows the passwords in clear text. Is there a way to handle this in subprocess api? I have multiple passwords to be passed.

Thanks!

0条回答
登录 后发表回答