calling a program from Python batch file
karim.farokhnia at gmail.com
Wed Dec 7 12:43:04 EST 2016
On Wednesday, December 7, 2016 at 12:18:51 PM UTC-5, Michael Torrie wrote:
> 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?
The program doesn't ask for more input parameters as all parameters are in input files and the program will automatically read the files, but I need to type in some required commands and press enter.
> > 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."
By [it] I meant the program.
More information about the Python-list