Hiding Console Output
placid
Bulkan at gmail.com
Wed Aug 2 20:34:59 EDT 2006
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