I have the following problem: from a Python script I need to run a CMD where I use 3 parameters, like below:
path_to/my.exe path/file.abc > path/file.txt
The closest solution found till now is something like:
os.system("start cmd /k D:/.../myexecutable.exe D:/.../file1.dat > D:/.../file1.txt")
But this only creates a blank file called file1.txt
, and in console I have the output produced by my EXE visible, but that content is not redirected to text file as I expect.
Also it will be nice to hide the console during the execution and wait for finish.
This part shall be applied to multiple files (this I manage to do).
Applying info from comments now the text is in the file, using this code:
os.system("cmd /k D:\\...\\myexecutable.exe D:\\...\\file1.dat ^> D:\\...\\file1.txt")
Left with one problem: in the command window, at end of file processing it's printed the path to my Python file. How can I close it?
a.exe b.dat > b.txt
how can I translate this to a subprocess call? – Adrian Jun 05 '20 at 13:21