This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author tzellman
Recipients
Date 2007-05-07.17:13:43
SpamBayes Score
Marked as misclassified
Message-id
In-reply-to
Content
An example:

>>> import subprocess
>>> proc = subprocess.Popen('"c:\Windows\system\ping.exe" "localhost"', shell=1, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

'c:\Windows\system32\ping.exe" "localhost' is not recognized as an internal or external command, operable program or batch file.

This normally works from the cmd.exe prompt, so the command line is being passed incorrectly in the subprocess module.

My ACTUAL use case arises when I want to call the Microsoft compiler (CL.exe), and add include directories that have spaces in the name. For example:

"C:\Program Files\Microsoft Visual Studio 8\VC\BIN\CL.exe" /TC /O2 /DNDEBUG /W3
/nologo /c /EHsc /errorReport:prompt /Idefault\ /I.. /I. /Idefault /I"C:\Program Files\GnuWin32" /DWIN32 ..\pcreposix.c /Fodefault\pcreposix.obj

The fix for this problem is to modify line 765 in subprocess.py, replacing it with:


args = comspec + " /s /c \"%s\"" % args.replace('""', '"')


The /s tells cmd.exe not to re-format the command line. We then encase the entire command line in double quotes. I also replace occurrences of "" with " in the arg string, in case the user already encased the command in double quotes.

With this fix, the commands execute correctly.
History
Date User Action Args
2007-08-23 14:53:37adminlinkissue1714451 messages
2007-08-23 14:53:37admincreate