Getting the entire output from subprocess.Popen

℡╲_俬逩灬. 提交于 2019-12-06 06:04:35

Is it going to stderr? Try redirecting:

p = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True).communicate()[0]

It's probably going to stderr, as SimonJ suggested.

Also, the docs say not to use shell=True in Windows for your case:

The executable argument specifies the program to execute. It is very seldom needed: Usually, the program to execute is defined by the args argument. If shell=True, the executable argument specifies which shell to use. On Unix, the default shell is /bin/sh. On Windows, the default shell is specified by the COMSPEC environment variable. The only reason you would need to specify shell=True on Windows is where the command you wish to execute is actually built in to the shell, eg dir, copy. You don’t need shell=True to run a batch file, nor to run a console-based executable.


Later: oh wait. Are you using the shell to get those environment variables expanded? Okay, I take it back: you do need the shell=True.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!