popen eating quotes?

Bryan belred1 at yahoo.com
Mon Aug 4 01:22:19 CEST 2003

"Jeff Epler" <jepler at unpythonic.net> wrote in message
news:mailman.1059942307.4825.python-list at python.org...
> This has been discussed before.  One such thread that I participated in
> was
> [apologies for the long URL, I don't know how to get a good memorable
> URL for a google groups search]
> This really is a cesspool on Windows, and the fault isn't Python's.
> Python is just calling the Windows functions, which insist on behaving
> badly compared to the Unix behavior.
> unix bigot'ly yours,
> jeff

thanks for the link, but it didn't help me solve my problem. i just read
many articles posted about popen and windows and there seems to be a
solution to this problem.  i need to pass a path to a program using popen so
i can capture the output.  since the path and/or file name can have spaces
in it, i need to quote it.   what's the way to get around this issue?  i saw
it mentioned in several places to try win32pipe.popen, but it had the same
problem as os.popen.  so, is this something that cannot be done in python at
all with no work-around?  is there another way besides using os.system or

>>> import os
>>> def run_args(arg):
...  i, o = os.popen4('"c:/program files/test/args.bat" -vv %s' % arg)
...  print o.read()
>>> run_args('"this is a very long path with spaces"')
'c:/program' is not recognized as an internal or external command,
operable program or batch file.



More information about the Python-list mailing list