stdout from spawn?

Charles Swiger cswiger at mac.com
Mon May 5 12:07:08 EDT 2003


On Monday, May 5, 2003, at 11:46 AM, Cipo Fuzo wrote:
> pid =
> os.spawnvp(os.P_NOWAIT,'tar',('tar','-tvf','/dev/tape','>','/tmp/ 
> tar.out'))
>
> tar errors out because it gets '>' and '/dev/tape' as an argument.

Spawn is a Windowsism for fork()ing a subprocess, right?  It calls  
"tar" directly, without invoking a shell...and shells are the things  
which handle the ">" redirection.

> I need to start this in the background, and also need the process id.
>
> Any ideas?

You can either perform the redirection yourself, by opening the  
/tmp/tar.out file and connecting stdout/stderr from tar to that file.   
Take a look at "pydoc popen2".

-Chuck






More information about the Python-list mailing list