command line - opening a batch file that opens a text file in python -


i writing script can execute batch file, needs open file in same folder first. current code is:

from subprocess import popen p = popen("mad8dl.bat <runthisto.txt>", cwd=r"c:\...\test") stdout, stderr = p.communicate() 

where ... path folder. however, everytime run syntax error:

the syntax of command incorrect 

any regarding syntax appreciated.

first, should remove < , > angle brackets code; pass filename, without brackets, batch file. (unless filename contain < , > characters, in case want know how managed since characters forbidden in filenames in windows).

second, code should like:

from subprocess import popen, pipe p = popen(["mad8dl.bat", "runthistoo.txt"], cwd=r"c:\...\test", stdout=pipe, stderr=pipe) stdout, stderr = p.communicate() 

note list containing components of call, rather single string. note need specify stdout=pipe , stderr=pipe in popen() call if want use communicate() later on.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -