How to run an EXE, with argument, capture output value

noydb noydb00 at gmail.com
Thu Nov 18 04:47:58 CET 2010


Hello All,

I would appreciate some guidance on this.  I'm a newbe, sorry if I
sound dumb - I kind of am on this stuff!

I have an executable that I want to run within python code.  The exe
requires an input text file, the user to click a 'compute' button, and
then the exe calculates several output values, one of which I want to
capture into a variable.  Can I use Python to supply the input file,
execute the exe and capture the output value, like such that the exe
really doesn't need to be 'seen'?  Or, would the user still have to
click the 'compute' button?

Any code snippets or guidance would be very much appreciated.  I have
found that

import os
os.system('C:\xTool\stats_hall.exe')

will run the exe.  And, maybe these execl/execle/execlp/etc functions
might be what I need for adding in the argument, but documentation
seems to indicate that these do not return output.  ??

Thanks much.



More information about the Python-list mailing list