Running a DOS exe file from python

Peter Hansen peter at engcorp.com
Fri Jan 27 12:45:40 EST 2006


Rinzwind wrote:
> Something like this:
> progname = 'c:\tmp\myprog.exe arg1 '+'-- help'
> os.system(r'progname)

Well, other than the ways in which it wouldn't work:

1. "arg1" doesn't get substituted with anything, if that's what you 
meant, but rather is inserted as the literal string "arg1".  If you 
meant that just as an example of some other argument that would be 
hardcoded, then it's unclear why you have the + in there since you could 
just have written the whole thing as a single string.

2. You need the 'r' meaning raw string *on the string literal*, in the 
first line, not in the second line.  In your code, the string bound to 
the name "progname" contains an ASCII TAB character in the third byte, 
after the "c" and the ":", which isn't likely what you wanted.

3. In the second line you have an unterminated string...




More information about the Python-list mailing list