Hiding Console Output
Kkaa
onlyafly at gmail.com
Thu Aug 3 10:55:07 EDT 2006
This seems like the right thing to do, but it runs the program in the
background, and I need my program to wait until the x.exe has finished.
I tried using this code:
p =
subprocess.Popen("x.exe",shell=True,stdout=subprocess.PIPE,stdin=subprocess.PIPE,
stderr=subprocess.PIPE)
sts = os.waitpid(p.pid, 0)
But I get the error: "No child process". Any ideas?
placid wrote:
> Kkaa wrote:
> > I'm using the os.system command in a python script on Windows to run a
> > batch file like this:
> >
> > os.system('x.exe')
> >
> > The third-party program x.exe outputs some text to the console that I
> > want to prevent from being displayed. Is there a way to prevent the
> > output of x.exe from python?
>
> using the subprocess module to create a subprocess and piping the
> stdout,stdin and stderr so you wont see any ouput from the process
> unless you read from the PIPE's.
>
>
> import subprocess
> p = subprocess.Popen("x.exe", shell=True,
> stdout=subprocess.PIPE,stdin=subprocess.PIPE, stderr=subprocess.PIPE)
>
>
>
> Cheers
>
> -
> http://bulkan.googlepages.com/python/
More information about the Python-list
mailing list