Capturing stdout from a console process?

Dave Brueck dbrueck at
Thu Dec 14 15:53:13 EST 2000

Hi Sam,

Use the os.popen* functions:

import os
w,r = os.popen4('xcopy c:*.* d: /v')
print # Prints stdout and stderr results of your command


> -----Original Message-----
> From: python-list-admin at
> [mailto:python-list-admin at]On Behalf Of Sam Schulenburg
> Sent: Thursday, December 14, 2000 12:59 PM
> To: python-list at
> Subject: Capturing stdout from a console process?
> I am using <os.system("xcopy c:*.* d: /v")> within a python program to
> copy files from one directory to another under windows NT. When the
> program executes, a new console window is created with the results of
> the xcopy command being displayed in the console window. Is 
> their a way
> to capture this output by python so I can log error messages?
> Sam Schulenburg
> Sent via
> -- 

More information about the Python-list mailing list