Update: When I use the subprocess.call
instead of subprocess.Popen
, the problem is solved - does anybody know what's the cause? And there came another problem: I can't seem to find a way to control the output... Is there a way to redirect the output from subprocess.call
to a string or something like that? Thanks!
I'm trying to use Devenv
to build projects, and it runs just fine when i type it in command prompt like devenv A.sln /build "Debug|Win32"
- but when I use a python to run it using Popen(cmd,shell=true)
where cmd
is the same line as above, it shows nothing. If I remove the |
, change it to "Debug"
only, it works....
Does anybody know why this happens? I've tried putting a \
before |
, but still nothing happened..
This is the code I am using:
from subprocess import Popen, PIPE
cmd = ' "C:\\Program Files\\Microsoft Visual Studio 8\\Common7\\IDE\\devenv" solution.sln /build "Debug|Win32" '
sys.stdout.flush()
p = Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE)
lines = []
for line in p.stdout.readlines():
lines.append(line)
out = string.join(lines)
print out
if out.strip():
print out.strip('\n')
sys.stdout.flush()
...which doesn't work, however, if I swap Debug|Win32
with Debug
, it works perfectly..
Thanks for every comment here