[Tutor] captering output of a cmd run using os.system.
Michael P. Reilly
arcege@speakeasy.net
Fri, 1 Jun 2001 07:45:31 -0400 (EDT)
alan.gauld@bt.com wrote
>
> ------_=_NextPart_001_01C0EA82.E7A76810
> Content-type: text/plain; charset="ISO-8859-1"
>
> > You can use the os.popen3 command instead.
>
> You might need to use the version of popwen in
> the winall package if you are on NT/W9x
> - it seems to work better...
WinXX os.popen also has a bug in GUI environments and will fail anyways
(which is why it doesn't work in the IDEs).
One win32all solution is:
>>> import win32pipe
>>> file = win32pipe.popen("echo Hello from Python", "r")
>>> file.read()
'Hello from Python\012'
>>>
There are other modules to help spawn programs this way.
If you wish to do a lot of WinXX Python programming, you might want to
get Hammond&Robinson's _Python Programming on Win32_.
-Arcege
--
+----------------------------------+-----------------------------------+
| Michael P. Reilly | arcege@speakeasy.net |