Has the python subprocess.Popen behaviour changed to print stderr always?


Has the python subprocess.Popen behaviour changed to print stderr always?



As per solutions here and python manual following code snippet must not print anything on screen, including stderr of the cmd.


cmd


p = subprocess.Popen(cmd, cwd=tmpdir, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
o, e = p.communicate()



But somehow I get the error messages of the cmd on terminal. Has the behaviour changed? I have tried following variant, and it has same results too:


cmd


p = subprocess.Popen(cmd, cwd=tmpdir, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
o, e = p.communicate()



I have Python 2.7.5 on CentOs 7.





Please show a Minimal, Complete, and Verifiable example. Particularly, what is cmd? And what, exactly, is the terminal output?
– user2357112
8 mins ago



cmd





cmd is a tool I use at my workplace and it takes only one argument which is a file. I'm not sure naming it will be any more helpful. Let me try to find another command which is widely available that can be used in this example.
– Akilan
3 mins ago




1 Answer
1



No, it didn't change. Your assumptions are wrong. Make sure you're running the correct piece of code, or try to find out what other things could be writing to the terminal. Because running a subprocess with stderr=subprocess.STDOUT will redirect all stderr output to stdout.


stderr=subprocess.STDOUT






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Possible Unhandled Promise Rejection (id: 0): ReferenceError: user is not defined ReferenceError: user is not defined

Opening a url is failing in Swift