unexpected os.system behavior on windows NT

Jeff Epler jepler at unpythonic.net
Wed May 8 14:37:42 EDT 2002


os.system seems to malfunction when the command name and another
argument are both quoted on the commandline.  All these commands
run "as expected" when executed directly in a command window.


>>> import os
>>> os.system(r'"cmd.exe" /c echo "hi bob"')
The system cannot find the path specified.
1
>>> os.system(r'"cmd.exe" /c echo hi bob')
hi bob
0
>>> os.system(r'cmd.exe /c echo "hi bob"')
"hi bob"
0

>>> os.system(r'cmd.exe /c echo "hi bob"')
"hi bob"
0
>>> os.system(r'cmd.exe /c "echo" "hi bob"')
The name specified is not recognized as an
internal or external command, operable program or batch file.
0
>>> os.system(r'cmd.exe /c "echo" hi bob')
hi bob
0

The same holds for os.popen, popen2.popen*, and win32pipe.popen*
though I haven't tried all the variations there.

I've kludged around this by using the 8.3 pathname for the executable,
so that I am guaranteed to not need to quote it ..

Jeff





More information about the Python-list mailing list