[Tutor] os.popen4 help!

Steven D'Aprano steve at pearwood.info
Tue Mar 16 23:08:34 CET 2010


On Wed, 17 Mar 2010 07:56:40 am Jeff Peery wrote:
> Hello,
> I'm trying to run an executable file from a python script. the
> executable is "opcenum.exe".
[...]
> currently I do the below:
>
> import os
> cmd = 'opcenum.exe/IOPCServerList/EnumClassesofCategory
> 63D5F432-CFE4-11d1-B2C8-0060083BA1FB' 
> fin,fout = os.popen4(cmd) 
> result = fout.read()
>
> this doesn't work, and it hangs up on fout.read(). 

What happens if you run the exact same command from the shell?

I assume you're using Windows. Open a DOS Window (command.com or cmd.exe 
or whatever it is called) and run:

opcenum.exe/IOPCServerList/EnumClassesofCategory 
63D5F432-CFE4-11d1-B2C8-0060083BA1FB

and see what it does.

Once you get the syntax right in the shell, then use the exact same 
syntax in popen4.



-- 
Steven D'Aprano


More information about the Tutor mailing list