I need to call an executable program with Python, let's say:
C:\Program Files\ANSYS Inc\v140\ansys\bin\winx64\ANSYS140.exe
I would need to have a txt file (afshin.txt) run with this executable application and then get the output file which is a txt file as well. In MATLAB for example it would be:
dos '"C:\Program Files\Ansys Inc\v121\ANSYS\bin\intel\ansys121.exe" -p AA_T_A -b -i afshin.txt -o file01.out'
mod_1 = load('output_res.txt');
Would you help me to do it in Python?
glglgl
91.5k13 gold badges157 silver badges230 bronze badges
2 Answers 2
Have a look at envoy, a sane wrapper around subprocess:
import envoy
r = envoy.run("C:\Program Files\Ansys Inc\v121\ANSYS\bin\intel\ansys121.exe -p AA_T_A -b -i afshin.txt -o file01.out")
mod_1 = open("output_res.txt").read()
print mod_1
answered May 14, 2012 at 14:37
Manuel Ebert
8,5595 gold badges42 silver badges63 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Colonel Panic
Yes use a high level library not the low level library
I have been use the following lines.
import os;
os.system("\"C:\\Apl\\ANSYS Inc\\v130\\ansys\\bin\\winx64\\ansys130.exe\" -b -j jobname -i InputFile.inp -o jobname.out");
Comments
lang-py
file01.outsame thanoutput_res.txt?subprocessmodule.