[python-win32] Bug with system()/popen() ?

Tim Roberts timr at probo.com
Fri May 13 19:19:22 CEST 2005


On Fri, 13 May 2005 05:08:13 -0400, "Ludvig Strigeus" 
<lstrigeus at accuratetechnologies.com> wrote:

>I'm trying to use system to run the following command:
>
>cmd  = C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe
>Argv[1] = /command:update
>Argv[2] = /path:"C:\Temp\Test"
>Argv[3] = /notempfile
>Argv[4] = /closeonend
>
>But all my attempts to convert this to a linearalized command line
>fails...
>
>This is my most successful try (don't ask me why i have "" at the start,
>it doesn't work at all otherwise):
>os.system('""C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe"
>/command:update /path:"C:\Temp\Test" /notempfile /closeonend')
>  
>

You know that you need to escape all of those backslashes, right?  You 
either need to use an r"xxx" string or double the backslashes.  \b (as 
in ...\bin) is the character with ASCII code 7.

>But this puts /path:C:\Temp /notempfile /closeonend into Argv[2].
>
>Doing just:
>os.system('"C:\Program Files\Tortoise SVN\bin\TortoiseProc.exe"
>/command:update /path:"C:\Temp\Test" /notempfile /closeonend')
>
>Prints that C:\Program is not a valid command or program.
>
>Any ideas? Is there some python function that doesn't require me to
>linearalize the command line, or is there some workaround so the above
>example works? (I need the functionality of popen())
>  
>

This is one reason why I always override the installation directory to 
one without spaces.

One alternative is to fall back to:
    os.system('c:\\progra~1\\tortoi~1\\bin\\TortoiseProc.exe 
/command:update /path:c:\\temp\\test /notempfile /closeonend')

Or:

  os.environ['PATH'] = os.environ['PATH'] + ';c:\\Program 
Files\\Tortoise SVN\\bin'
  os.system('TortoiseProc.exe /command: ...')

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-win32 mailing list