calling a program from Python batch file

Michael Torrie torriem at gmail.com
Wed Dec 7 13:23:02 EST 2016


On 12/07/2016 10:59 AM, John Gordon wrote:
> In <f9d6e83d-d8e7-4245-a02f-9065572632a9 at googlegroups.com> Karim Farokhnia <karim.farokhnia at gmail.com> writes:
> 
>> Hi there,
> 
>> I am writing a batch file in Python. The batch file, in part, calls a
>> program named "oq-console.bat" to run. Then once the program comes up
>> (it looks like windows CMD), I need the batch file to type some commands
>> to make it run (just like I would do it by myself).
> 
> If you need to start up a program, provide interactive input to it, and
> perhaps examine its interactive output, then you want the "pexpect" module:
> 
>     Pexpect is a pure Python module for spawning child applications;
>     controlling them; and responding to expected patterns in their output.
>     Pexpect allows your script to spawn a child application and control it
>     as if a human were typing commands.
> 
>     https://pexpect.readthedocs.io/en/stable/

Does Pexpect work on Windows?

In the OP's case it looks like the standard in pipe is sufficient.




More information about the Python-list mailing list