Capture output from stderr

Grant Edwards grante at visi.com
Tue Aug 5 20:30:13 EDT 2003


In article <a7a67196.0308051626.393446ea at posting.google.com>, klappnase wrote:

> I am trying to program a Tkinter application for linux, so I want to
> run a shell command from the gui and capture its output on the fly
> while the process is still running in order to display the progress
> messages in a toplevel window so the user may watch what is going on
> (the execution of the shell command may take a few minutes). Because
> the output is printed to stderr I thought I should use a popen2.Popen4
> instance for that, like:
> 
>         self.pp = popen2.Popen4("exec cmd")
> 
> I tried something like 
> 
>     def getmsg(self):
>         msg = self.pp.fromchild
>         newmsg = msg.read(100)
>         ...(do something)...
>         self.master.after(1000, self.getmsg)

I've always used a read handler for this in the past, and it worked fine.
I don't have an example handy...

-- 
Grant Edwards                   grante             Yow!  Like I always
                                  at               say -- nothing can beat
                               visi.com            the BRATWURST here in
                                                   DUSSELDORF!!




More information about the Python-list mailing list