Redirect DOS command output

Aahz Maruch aahz at netcom.com
Thu Feb 10 13:25:17 EST 2000


In article <87ura9$ib0$1 at nnrp1.deja.com>,  <daryl_stultz at my-deja.com> wrote:
>
>Hey, I'm using os.system() to execute a DOS command (on an NT machine).
>I would like to capture (and parse) the output from the command. I'm
>familiar with sys.stout but I'm not sure how to do this.

You either need to redirect the output to a file (e.g.

   os.system("foo > bar")

) or capture the output directly:

   os.popen("foo")

Note that os.popen() is known to have some problems on Win9x (for more
info see the Python FAQ).
--
                      --- Aahz (Copyright 2000 by aahz at netcom.com)

Androgynous poly kinky vanilla queer het    <*>     http://www.rahul.net/aahz/
Hugs and backrubs -- I break Rule 6

Nostalgia just ain't what it used to be



More information about the Python-list mailing list