Redirect output from os.system()

Steve Holden sholden at holdenweb.com
Tue Nov 27 14:06:14 EST 2001


"Era Akost" <era_akost at yahoo.de> wrote ...
> Hi all,
>
> Searching through the group emails, I've found out how to redirect
> output from python functions. Now I would like to redirect the output
> from a os.system() process to a Text widget. How can I do it?
>
> Python Reference Library  says the following on stdout, stdin of sys
> module:
>
> "(Changing these objects doesn't affect the standard I/O streams of
> processes executed by os.popen(), os.system() or the exec*() family of
> functions in the
> os module.)"
>
> So, what should be done??

Instead of calling system(), use one of the popen()'s to give you a
pipeline, which will allow you to read the output from the process and do
with it what you will.

regards
 Steve
--
http://www.holdenweb.com/








More information about the Python-list mailing list