os.system stdout redirection...

mackstann mack at incise.org
Sun Aug 17 02:19:04 EDT 2003


On Sun, Aug 17, 2003 at 01:01:41AM -0500, Terry Gray wrote:
> Using Python 2.2 in Debian linuxI am trying to change to a different 
> directory, execute a 'make all' command, and redirect the output of the 
> subshell to a PyQt window...  I should be able to execute the 
> os.system('cd newdirectory; make all'), but how do I redirect stdout of 
> the new subshell created by the os.system call?
> 
> Any help would be appreciated.

You can use os.popen (popen2 and 3 as well), or the popen2 module's
Popen3 and 4 classes, or commands.getoutput (and there are probably even
more ways :).

-- 
m a c k s t a n n  mack @ incise.org  http://incise.org
While having never invented a sin, I'm trying to perfect several.





More information about the Python-list mailing list