Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #11542

Re: subprocess.Popen question

From Nobody <nobody@nowhere.com>
Subject Re: subprocess.Popen question
Date 2011-08-16 12:26 +0100
Message-Id <pan.2011.08.16.11.26.39.186000@nowhere.com>
Newsgroups comp.lang.python
References <4E49AB3E.9000801@web.de> <mailman.39.1313478249.27778.python-list@python.org>
Organization Zen Internet

Show all headers | View raw


On Tue, 16 Aug 2011 02:03:50 -0500, Danny Wong (dannwong) wrote:

> 	I'm executing a command which I want to capture the
> standard/stderr output into a file (which I have with the code below),
> but I also want the standard output to go into a variable so I can
> process the information for the next command. Any ideas? Thanks.
> 
> CMD_OUTPUT = subprocess.Popen(COMMAND, stdout=PROJECT_LOGFILE,
> stderr=subprocess.STDOUT)

	CMD_OUTPUT.wait()
	with open(PROJECT_LOGFILE,'r') as f:
	  str = f.read()

If you're going to be writing it to a file anyhow, reading that file is
likely to be faster than the alternatives.

Back to comp.lang.python | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

subprocess.Popen question "Danny Wong (dannwong)" <dannwong@cisco.com> - 2011-08-16 02:03 -0500
  Re: subprocess.Popen question Thomas Rachel <nutznetz-0c1b6768-bfa9-48d5-a470-7603bd3aa915@spamschutz.glglgl.de> - 2011-08-16 11:10 +0200
  Re: subprocess.Popen question Nobody <nobody@nowhere.com> - 2011-08-16 12:26 +0100

csiph-web