1

I am working in Windows, and just learning to use python (python 2.7).

I have a bunch of script files ("file1.script", "file2.script", "file3.script"....) that are executed in TheProgram.exe. Python has already given me the ability to automatically create these script files, but now I want to successively run each of these script files, back-to-back, in TheProgram.exe.

So far I have figured out how to use the subprocess module in python to start "TheProgram.exe" in a new process (child process?) and load the first script file as follows:

my_process = subprocess.Popen(["Path to TheProgram.exe", "Path to File1.script"])

As seen, simply "opening" the script file in TheProgram.exe, or passing it as an argument in this case, will execute it. Once File1.script is done, TheProgram.exe generates an output file, and then just sits there. It does not terminate. This is I want, because now I would like to load File2.script in the same process without terminating (file2.script is dependent on file1.script completing successfully), then File3.script etc.

Is this possible? And if so how? I cannot seem to find any documentation or anyone else who has had this problem. If I can provide other information please let me know, I am also new to posting to these forums. Thanks so much for any assistance.

5
  • What is TheProgram.exe exactly? Is it calling Python, or only called by Python? Can't you just pass multiple script arguments to TheProgram.exe in Popen? Commented Sep 28, 2013 at 2:18
  • I think what I did in my answer to the question "Python on Windows: Run multiple programs sequentially in one command prompt" for batch files would apply to any script file. Commented Sep 28, 2013 at 3:28
  • @JohnZwinck -- It is called by python. (it is just a simulation program that uses .script files to run its functionality.) I see what you are saying, pass multiple file arguments to Popen. The only problem with this is I want to return to python functionality between script runs. I have to make control decisions between each script file that determines how the next script file will run. I think passing multiple arguments would just iterate through them without the ability to make control decisions in between (right?). Sorry if that was not clear in the original question. Commented Sep 28, 2013 at 16:24
  • @martineau -- Do you have any recommendations for where to read about batch files? The question and answer that you linked is almost identical to my problem, except instead of running the .script files in windows command line, they are being run by the simulation program "TheProgram.exe". Would this make a difference? His issue with needing to process output files before starting the next script is identical to mine. Commented Sep 28, 2013 at 16:37
  • @user112358: Batch files are mainly just a series of commands that could otherwise be typed into the Windows command console. There are a few additional commands like if and goto that only make sense within a batch file though. Anyway there's literally tons of information about them on the web and in Windows' own help files. I think the main difference is that you'll be using TheProgram.exe instead of cmd.exe (which is the name of the Windows console program). Commented Sep 28, 2013 at 17:28

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.