[Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000
Guido van Rossum
guido at python.org
Fri Aug 8 21:53:08 EDT 2003
More information about the Python-Dev mailing list
Fri Aug 8 21:53:08 EDT 2003
- Previous message: [Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000
- Next message: [Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
> [Kurt B. Kaiser, struggles to get an embedded-space spawn to work] [Tim, can't belp helping] > I think the trick is that you shouldn't quote the executable path at all. > Under the covers, MS takes the executable name as-is, passing it as the > lpApplicationName argument to the Win32 CreateProcess(), but squashes all > your *arguments* into a single string, which gets passed on as the > lpCommandLine argument to CreateProcess(). > > In the arguments, you should avoid the cleverness of trying to quote only > the part(s) with a space(s). Stick a double quote on each end of each > argument, and that's it(*). > > So, for example, I made a copy of a wc.exe into > > c:\Program Files\tmp\w c.exe > > and then this Python works (on Win98SE(*)) to run that program on itself: > > """ > raw = r'C:\Program Files\tmp\w c.exe' > > import os > print os.path.exists(raw) > > decorated = '"%s"' % raw > os.spawnv(os.P_NOWAIT, raw, (decorated, decorated)) > """ > > Here's the output: > > C:\Code\python\PCbuild>python temp2.py > True > 26 203 13824 C:\Program Files\tmp\w c.exe > > C:\Code\python\PCbuild> > > So I expect that IDLE is getting in trouble because it's not stuffing quotes > around an *argument* to a program it's spawning. > > > (*) There the fun begins. While os.system() spawns a command shell, > I don't think spawnv() does. Which would be a real help here. > Win9x use command.com by default, and Windows after that use > cmd.exe. They have have different quoting rules, and cmd.exe > actually has two different sets of quoting rules (triggered by > an option to cmd.exe, and/or by a registry setting). > > Still, I haven't tried the program above on a Win2K (etc) > system, and somebody should before you get optimistic. In one > of cmd.exe's quoting nightmare modes, whether double quotes > get stripped actually depends on the content of the quoted > string <arghghghgh>! Right. I'm pretty sure that the quoting rules are different on 9x/Me on the one hand and on NT/2K/XP OTOH (though the real reason may be the different default shell). For example, on my 98se laptop, in a DOS shell, cd \Program Files says Too any parameters - files while this works on the XP (still -- Red Hat Linux 9.0 coming soon :-) box at work. --Guido van Rossum (home page: http://www.python.org/~guido/)
- Previous message: [Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000
- Next message: [Python-Dev] Re: FWD: Re: Problem w/ IDLE on Win2000
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-Dev mailing list