calling a program from Python batch file

Michael Torrie torriem at gmail.com
Wed Dec 7 12:18:33 EST 2016


On 12/07/2016 09:38 AM, Karim Farokhnia wrote:
> 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).
> 
> I need the batch file does the whole things automatically, I mean
> calls the program, types in commands and press enter!

Is the program that oq-console.bat runs interactive?  After it launches
into its own console window it asks for more input?

> So far, I have used the below Python codes in my batch file to do
> that;
> 
> 
> import subprocess
> 
> subprocess.call(["C:\Program Files (x86)\OpenQuake
> Engine\oq-console.bat", "oq --run", "job.ini"])
> 
> 
> Note that the first string is the program, and the last two are the
> commands which needs to be typed in.
> 
> It pulls up the program well, but doesn't type in the commands to
> make it to run.

You'll have to explain what you mean by "[it] doesn't type ni the
commands to make it run."




More information about the Python-list mailing list