windows - python - path printed inside output -
i have py file inside:
from subprocess import popen programme = "path program.exe" file = "path file used program.exe" p = popen([program, file]) print p.stdout.read()
and when do:
c:\>python file.py
in cmd got
#output #.... #... more output c:\:>#...more output #.... #...here finishes output
why appearing "c:\>
" ? because popen in order run command gave... needed create new process?
thanks in advance
pd: using windows server 2008 python 2.7.5
the python script ends after starting process, , prompt returns (printing c:\>
). subprocess still running, , stdout , stderr defaults write in console if not redirected, continues output , writes on returned prompt.
what want wait subprocess end, first
subprocess.call([program, file])
(if you're printing stdout there's no need that's default.)
if need access stdout, redirect stdout , utilize communicate.
p = subprocess.popen([program, file], stdout=subprocess.pipe, stderr=subprocess.pipe) stdout, stderr = p.communicate() print stdout
python windows subprocess popen
No comments:
Post a Comment