Reputation: 13
I am new to Python. I use a molecular modeling program (Fortran, no source code) that runs from the Windows command prompt that prompts a user to insert variables, e.g. symmetry, number of molecules, file name, etc., and then runs a simulation and outputs the results of the simulation as .pdb and .txt files. In the modeling program I have to wait for specific prompts to input each variable.
I would like to automate the input process with python, changing one variable each time. The python program would look like this:
1) Initiate the modeling program ("ranch")
2) Input var 1, var 2, var 3, etc. in order, when prompted by the program.
3) Generate the output files
4) Go back to number one with a new var 1, keeping all other variables the same.
I can't figure out how to do step 2. I think subprocess should work, but I can't figure out how to input each variable only when prompted by the modeling program. Is it even possible to do this?
Thanks. I am running Windows 7.
Upvotes: 1
Views: 2442
Reputation: 760
You want to look at pexpect. But since you're on windows you'd want to look at wexpect
Upvotes: 0
Reputation: 8492
You want to look into the subprocess
module, specifically Popen.communicate()
with stdout=subprocess.PIPE, stdin=subprocess.PIPE
set.
This link gives some pretty good examples.
Upvotes: 0