0

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?

3
  • 1
    in your example is file01.out same than output_res.txt ? Commented May 14, 2012 at 14:01
  • 4
    There are plenty of good examples in the documentation of the subprocess module. Commented May 14, 2012 at 14:03
  • 1
    yes, and a quick search gives a solution for the first part ; stackoverflow.com/questions/89228/… Commented May 14, 2012 at 14:05

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Yes use a high level library not the low level library
1

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

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.