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.

classification
Title: popen fails when there are two or more pathnames/parameters with spaces
Type: behavior Stage:
Components: Library (Lib), Windows Versions: Python 2.4, Python 2.5
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: christian.heimes, shoermann, thomaslee
Priority: normal Keywords:

Created on 2008-01-09 06:22 by shoermann, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
popen_bug.py shoermann, 2008-01-14 21:53 Code that shows the bug
Messages (4)
msg59580 - (view) Author: Stephan Hoermann (shoermann) Date: 2008-01-09 06:22
If commands similar to this (including all quotation 
marks) '"C:\\Program Files\\test.bat" blah "C:\\Data Files\\test2.txt"' 
are executed using popen, then the following is returned from 
stderr "'C:\\Program' is not recognized as an internal or external 
command,\noperable program or batch file.\n". No use of quotation has 
been able to fix this. As soon as there is more than one pair of 
quotations inside the command string popen will not handle the command 
correctly.
msg59898 - (view) Author: Thomas Lee (thomaslee) (Python committer) Date: 2008-01-14 13:37
Do you have a code sample that reproduces this issue? Which popen module
and/or function are you using to execute this command?
msg59925 - (view) Author: Stephan Hoermann (shoermann) Date: 2008-01-14 21:53
I have attached some code that demonstrates the bug. You need to run it 
on Windows and you need to place some bat file (it doesn't need to do 
anything just exist) at C:\Program Files\test.bat (or change the 
reference in the code, but it does need to include spacing). The first 
popen call works the second popen call will fail, because there are 2 
pathnames in the code with spaces. I am using the popen4 module in os 
but I also tested popen2 and popen3 and they do the same thing.
msg61358 - (view) Author: Christian Heimes (christian.heimes) * (Python committer) Date: 2008-01-20 19:56
The popen*() function don't quote the paths for you. Please use the
subprocess module. It takes care of the quoting on Windows.
History
Date User Action Args
2022-04-11 14:56:29adminsetgithub: 46105
2008-01-20 19:56:54christian.heimessetstatus: open -> closed
resolution: works for me
messages: + msg61358
nosy: + christian.heimes
2008-01-14 21:53:27shoermannsetfiles: + popen_bug.py
messages: + msg59925
2008-01-14 13:37:33thomasleesetnosy: + thomaslee
messages: + msg59898
2008-01-09 06:22:57shoermanncreate