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.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to