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?

glglgl
91.5k13 gold badges157 silver badges230 bronze badges
asked May 14, 2012 at 13:55
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
answered May 14, 2012 at 14:37
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");
answered Jun 21, 2012 at 14:19

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.