[Tutor] Output of os.system("c:\myprog.exe") "piped" to a python
object ?
Marcel Preda
marcel@punto.it
Tue, 10 Oct 2000 19:23:59 +0200 (CEST)
On Tue, 10 Oct 2000, nicolas baurin wrote:
> Hello to everybody,
>=20
> clearly i'm using os.system() to launch an external program ;i have to
> "redirect" what comes into the console (standard output of the external
> program) towards a python object: sys.stdout is not enough since it's
> applying to the python interpretor...
>=20
> Merci d'avances et bonne soir=E9e,
On Unix you can use `popen' like that:
#!/usr/local/python2.0/bin/python
import os
fileObj=3Dos.popen('/bin/ls')
a=3D1
raw_input("will print the result (after Enter):")
while (a):
a=3DfileObj.readline()
print a
I dont have here a Win to tel you more about this,
look at the popen2 module, if popen don't work...
PM