os.system stdout redirection...

Terry Gray tgray at cox-internet.com
Sun Aug 17 15:43:44 EDT 2003


mackstann wrote:
> 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 :).
> 
All the Python docs I've been looking at must have been pre-2.0, because 
this is the first I've heard of the popen2/3/Popen3/4 calls.  Anyway, is 
there a recommended way of capturing 'make's' output, line by line, and 
redirecting it to a PyQt window?  The window in question is a QTextEdit 
control with a 'def write' function.

Again, thanks for the help.





More information about the Python-list mailing list