Spaces in path name

Tim Golden mail at timgolden.me.uk
Sun Mar 16 03:42:31 EDT 2008


Tim Golden wrote:
> joep wrote:
>> On Mar 15, 5:42 pm, joep <josef.p... at gmail.com> wrote:
>>>> http://timgolden.me.uk/python/win32_how_do_i/run-a-command-with-a-spa...
>>> Note: this works for subprocess.call but for subprocess.Popen this
>>> does not work if there are two arguments in the command line with
>>> spaces. Especially, even after trying out many different versions, I
>>> never managed to get subprocess.Popen to work, when both the
>>> executable and one argument have spaces in the file path.
>>>
>> Sorry, incomplete sentence
>>
>> Especially, even after trying out many different versions, I never
>> managed to get subprocess.Popen to work '''when command line is given
>> as a *list* argument to subprocess.Popen'''
>> in the case when both the executable and one argument have spaces in
>> the file path.

Following up, I'm a little bemused. Below is a command which works on
a Win2K Python 2.4 installation (and on WinXP with Python 2.5).
I've deliberately chosen something in Program Files and I've copied both
the executable and the document so that even the base filenames have
embedded spaces, as well as the directory path to get there.
(The lines are quite long: you'll probably have to piece them
together a bit; that's why I've put an extra line space between
each.)

subprocess.call ([

   r"C:\Program Files\Adobe\Acrobat 5.0\Reader\acro reader.exe",

r"C:\Program Files\Adobe\Acr
obat 5.0\Reader\plug_ins.donotuse\Annotations\Stamps\abc def.pdf"

])

Can you confirm that something equivalent *doesn't* work on your
setup? Or have I misunderstood your point earlier? I'd really
like to get to the point where we can definitively state: this
works (and possibly: that doesn't).

Thanks
TJG




More information about the Python-list mailing list