pythonwexpect

run an executable using wexpect


I have an executable (evapo.exe) which has to be called with an input file (inputs.prj), usually I do it using windows command prompt by just typing c:\myfiles\evapo inputs.prj (of course both the executable and input file located in myfiles folder)

Now I want to be able to do the same thing using python. Other similar questions here on SO suggested to use wexpect since other methods such as subprocess do not work when the executable askes for other informations to run (for my case the information being the input file). i tried:

import wexpect

wexpect.run(r'c:\myfiles\evapo.exe')

and python hangs..., please help me if anyone has an idea how i can combine the exe and input file as I do it using cmd.


Solution

  • You don't need wexpect if all information you want to pass is a file name:

    from subprocess import check_call
    
    check_call(r'c:\myfiles\evapo.exe inputs.prj')