473,395 Members | 2,713 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

subprocess-how to suppress the stdout

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
3 8357
"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Michael McGarry | last post by:
Hi, I am just starting to use Python. Does Python have all the regular expression features of Perl? Is Python missing any features available in Perl? Thanks, Michael
5
by: Michele Simionato | last post by:
I was looking at Python 2.4 subprocess.Popen. Quite nice and handy, but I wonder why a "kill" method is missing. I am just adding it via subclassing, class Popen(subprocess.Popen): def...
1
by: Earl Eiland | last post by:
I calling a Windows executable with PROC = subprocess.Popen('...'), and blocking further python execution until the process terminates with PROC.wait(). Occasionally, something unusual happens...
14
by: Ernesto | last post by:
def launchWithoutConsole(command, args): """Launches 'command' windowless and waits until finished""" startupinfo = subprocess.STARTUPINFO() startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW...
6
by: Ernesto | last post by:
I'm opening a telnet session with the subprocess call below. I then wait ten seconds and attempt to terminate the telnet window I created. Unfortuantely, the telnet window remains after the...
5
by: Grant Edwards | last post by:
I'm trying to use the py-gnuplot module on windows, and have been unable to get it to work reliably under Win2K and WinXP. By default, it uses popen(gnuplotcmd,'w'), but in some situations that...
3
by: Lee | last post by:
Has anyone ran into this problem? I've done extensive googling and research and I cannot seem to find the answer. I downloaded the source for 2.5.1 from python.org compiled and installed it on a...
23
by: Harishankar | last post by:
Hi, Sorry to start off on a negative note in the list, but I feel that the Python subprocess module is sorely deficient because it lacks a mechanism to: 1. Create non-blocking pipes which can...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
0
by: Gabriel Genellina | last post by:
En Fri, 05 Sep 2008 09:56:02 -0300, tarun <tarundevnani@gmail.com> escribió: Add this argument: creationflags = subprocess.CREATE_NEW_CONSOLE See "Creation of a Console" in MSDN:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.