calling a program from Python batch file
John Gordon
gordon at panix.com
Wed Dec 7 12:59:39 EST 2016
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/
--
John Gordon A is for Amy, who fell down the stairs
gordon at panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
More information about the Python-list
mailing list