newbie troubles: os.popen confusion

Jelle Feringa // EZCT / Paris jelle.feringa at ezct.net
Mon Nov 1 08:46:43 EST 2004


Hi,

I'm learning python at the moment, and am trying to write some basic shell
scripts to start off with.
I having trouble executing programs from within python.
Very basic operations such as:

>>>listing = os.popen('dir /B').readlines()

work out just fine, but when I do the same thing with a specific program, it
doenst work out.

>>>mr = os.popen(str(os.environ['MI_ROOT']) + 'ray3.exe').readlines()
>>>mr
[]

So I tried calling the program using win32pipe.
The program gets launched, but when I try to connect to its output
--o.readlines()-- the script is stuck until the process is killed.
Also it seems to me that using win32pipe.popen2 options are specified in a
different way than in os.popen where I can specify these directly.
Could you put me in the right direction?

Cheers,

Jelle.

>>>mr, o = win32pipe.popen2(str(os.environ['MI_ROOT']) + 'ray3.exe')

	---actually "mr, o = win32pipe.popen2('ray3.exe')" does the same
thing, its finding the program in the environment---

>>>mr

<open file 'C:\Softimage\XSI_4.0\Application\bin\nt-x86-p3\ray3.exe', mode
'w' at 0x018735E0>

>>>o.readlines()

stops running the script until I kill the process







More information about the Python-list mailing list