By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,897 Members | 1,490 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,897 IT Pros & Developers. It's quick & easy.

subprocess-how to suppress the stdout

P: n/a
alf
Hi,
I use subprocess to execute another program but need to suppress its stdout.

I can achieve it by using Popen(...,stdout=subprocess.PIPE,...) but
wonder where the all stdout actually goes. Is it buffered (to eventually
fill up)or just discarded?

Or there is a better solution ...

Thx, alf
Oct 26 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"alf" <as*@me.xs4all.nlwrote:
I can achieve it by using Popen(...,stdout=subprocess.PIPE,...) but
wonder where the all stdout actually goes. Is it buffered (to eventually
fill up)
it ends up in a pipe buffer, yes.
Or there is a better solution ...
/dev/null is your friend:

Popen(..., stdout=open("/dev/null", "w"), stderr=subprocess.STDOUT, ...)

</F>

Oct 26 '06 #2

P: n/a
alf
Fredrik Lundh wrote:
"alf" <as*@me.xs4all.nlwrote:

>>I can achieve it by using Popen(...,stdout=subprocess.PIPE,...) but
wonder where the all stdout actually goes. Is it buffered (to eventually
fill up)


it ends up in a pipe buffer, yes.

>>Or there is a better solution ...


/dev/null is your friend:

Popen(..., stdout=open("/dev/null", "w"), stderr=subprocess.STDOUT, ...)
I am forced to use win32 :-( plus it needs to be platform independent ...
Oct 26 '06 #3

P: n/a
alf wrote:
>/dev/null is your friend:

Popen(..., stdout=open("/dev/null", "w"), stderr=subprocess.STDOUT, ...)

I am forced to use win32 :-( plus it needs to be platform independent ...
alright, os.devnull is your friend:

Popen(..., stdout=open(os.devnull, "w"), stderr=subprocess.STDOUT, ...)

</F>

Oct 26 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.