Update: When I use subprocess.call instead of subprocess.Popen , the problem is solved - does anyone know what is the reason? And another problem came up: I canβt 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 try to use Devenv to create projects, and it works fine when I enter it on the command line, for example devenv A.sln /build "Debug|Win32" , but when I use python to run it using Popen(cmd,shell=true) , where cmd is the same line as above, it shows nothing. If I remove | , change it only to "Debug" , it will work ...
Does anyone know why this is happening? I tried to put \ before | but still nothing happened.
This is the code I'm 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 does not work, however, if I change Debug|Win32 to Debug , it works fine.
Thanks for every comment here.
python subprocess
hyou
source share