redirecting output from spawned processes

Pearu Peterson pearu at cens.ioc.ee
Fri Nov 15 15:43:10 EST 2002


On 15 Nov 2002, Trent Mick wrote:

> [Jef Mangelschots wrote]
> > How do I redirect the output of 'someapp' to the file log_file ?
> > 
> > 
> >            log_file = 'c:\output.log'
> > 
> >            os.spawnv(os.P_WAIT, 'some_app', 'p1', 'p2')
> 
> A couple of ways:
> 
>     os.system("someapp > %s" % log_file)
...
> I think you want the former though. To redirect stderr as well you need
> to do a little bit more work:
> 
>     os.system("someapp > %s 2>&1" % log_file)

Does it really work under windows? From log_file I gather that Jef asked
this for Windows platform.

Pearu





More information about the Python-list mailing list