[python-win32] os.popen4 and spaces in the directory name

Stephen Briley sdb1031 at gmail.com
Sat Dec 3 20:43:38 CET 2005


Hi all,

I would like to run a program via the os.popen (or similar) commands.
However, the path to the executable that I would like to run contains spaces
(e.g. C:\program files\some directory\engine\theexe.exe).  The python syntax
that I am using is as follows:

>>> os.popen4("C:\program files\some directory\engine\theexe.exe")[1].read()

When I try to run it, I get the following message:
"'C:\\program' is not recognized as an internal or external
command,\noperable program or batch file.\n"

So, the space for "program files" is messing it up.  I thought that I could
get around that by using progra~1:
>>> os.popen4("C:\progra~1\some directory\engine\theexe.exe")[1].read()

When I try to run it, I get the following message:
"'C:\\progra~1\\some' is not recognized as an internal or external
command,\noperable program or batch file.\n

This time, it doesn't like the directory named "some directory".  Is there
any way around this?  The command runs fine if I open up a Windows command
prompt and specify the full directory path to the exe.  I am using python
2.4 on a Windows 2003 server.  I am also running this command on Windows
2003 server.

Thanks,
Steve
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20051203/51057ca1/attachment.html


More information about the Python-win32 mailing list