0

I am running an executable from cmd:

*.exe input.inp

I want to run it using python and tried following:

os.system('"*.exe"') 

But don't know how to specify input file as well. Any suggestions?

2

3 Answers 3

1
import os
from subprocess import Popen, PIPE

p = Popen('fortranExecutable', stdin=PIPE) #NOTE: no shell=True here
p.communicate(os.linesep.join(["input 1", "input 2"]))

For more please refer to:

Using Python to run executable and fill in user input

Sign up to request clarification or add additional context in comments.

Comments

0

I had to launch cmd window and specify input file location from within Python script. This page was really helpful in getting it done.

I used Popen(['cmd', '/K', 'command']) from above page and replaced '/K' with '/C' in it to run and close the cmd window.

Comments

0
import os
os.system(r'pathToExe.exe inputFileOrWhateverOtherCommand')

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.