output.txt" it works perfect but i need to do this from python code, how is this..." /> output.txt" it works perfect but i need to do this from python code, how is this..." /> output.txt" it works perfect but i need to do this from python code, how is this..."/>

python run .exe app with argument

4.1k Views Asked by At

If i write this in command prompt: "senna-win32.exe < input.txt >output.txt" it works perfect but i need to do this from python code, how is this possible?

I have tried:

import subprocess
subprocess.call([pathToExe, "input.txt" , "output.txt"])

import subprocess
subprocess.call([pathToExe, '< input.txt > output.txt'])

I'm getting error of "invalid argument < input.txt > output.txt".

1

There are 1 best solutions below

0
On BEST ANSWER

Thank you Jack!!!

import subprocess
myinput = open('in.txt')
myoutput = open('out.txt', 'w')
p = subprocess.Popen('senna-win32.exe', stdin=myinput, stdout=myoutput)
p.wait()
myoutput.flush()