Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!feeds.phibee-telecom.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:Windows': 0.02; 'syntax': 0.04; 'linux,': 0.07; 'subject:PEP': 0.07; 'subject:support': 0.07; 'bash': 0.09; 'subject:using': 0.09; 'windows': 0.15; 'behaviour.': 0.16; 'command.com': 0.16; 'commandline': 0.16; 'differs': 0.16; 'issue?': 0.16; 'pywin32': 0.16; 'subject: \n ': 0.16; 'subject:API': 0.16; 'files.': 0.16; 'wrote:': 0.18; 'normally': 0.19; 'skip:p 40': 0.19; 'stefan': 0.19; 'shell': 0.22; 'header:User-Agent:1': 0.23; 'subject: .': 0.24; 'cheers,': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'rest': 0.29; 'that.': 0.31; 'overhead': 0.31; 'requesting': 0.31; 'file': 0.32; 'run': 0.32; 'running': 0.33; 'subject:from': 0.34; 'problem.': 0.35; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'doing': 0.36; "didn't": 0.36; 'should': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'expect': 0.39; 'to:addr:python.org': 0.39; 'commands': 0.60; 'services,': 0.61; 'simple': 0.61; "you're": 0.61; 'address': 0.63; 'such': 0.63; 'more': 0.64; 'charset:windows-1252': 0.65; 'worth': 0.66; 'services': 0.66; 'sample': 0.67; 'received:74.208': 0.68; 'default': 0.69; 'heavy': 0.81; 'fortunately': 0.84; 'internally.': 0.84; 'subject:skip:F 10': 0.84; 'mistake': 0.91; 'before?': 0.93 Date: Wed, 06 May 2015 20:58:13 -0400 From: Dave Angel User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API References: In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:77xq8pkiDDwqgFCuXSl0KeWswkzNBI01+2urm/9rTVq5vEXtQHT ofwjSQYSg4L1Kzx+br4c0MBn4WuAyKuYQFTocRt0QygFiaavLUjgWzhYud9J6O2sMiohWMF oh9BtIEcECjgOgKPOQVL620vEQnYu5fnu01QFiU/T4uvoaUPxHR5/89wgYk4cBEBtV0FjTf r/4btHpD4dOPXtkvqB+dA== X-UI-Out-Filterresults: notjunk:1; X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 43 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1430960306 news.xs4all.nl 2932 [2001:888:2000:d::a6]:46641 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:90081 On 05/06/2015 06:11 PM, Stefan Zimmermann wrote: > Hi. > > I don't like that subprocess.Popen(['command']) only works on Windows if there is a command.exe in %PATH%. As a Windows user you would normally expect that also command.bat and command.cmd can be run that way. > and command.com. If it's really unfortunate that you picked "command" for your sample program name. Since command.com was the shell in MSDOS, I was about to point you to COMSPEC to address your problem. There's nothing Windows-specific about that behaviour. In Linux, there are bash commands that can only be run by using shell=True. Fortunately Popen didn't make the mistake of pretending it's a shell. There is lots more to running a batch file than launching it. The whole syntax of the rest of the commandline differs when you're doing that. > There are simple workarounds like Popen(..., shell=True) but that is a heavy overhead for .exe files. And the reason there's such an overhead is because you're requesting the services of the shell. If you don't need those services, use shell=False. > > Currently I use pywin32 and call Popen([win32api.FindExecutable('command')[1]]) as a workaround. This has zero overhead. > > It should be default for Popen to call FindExecutable internally. > > Was this discussed before? > Is it worth a PEP? > Or at least an issue? > > Cheers, > Stefan > -- DaveA