Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #90081

Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API

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 <davea@davea.name>
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 <davea@davea.name>
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 <a0a85a0a-555f-4fff-bc1f-49873dd297c5@googlegroups.com>
In-Reply-To <a0a85a0a-555f-4fff-bc1f-49873dd297c5@googlegroups.com>
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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.195.1430960306.12865.python-list@python.org> (permalink)
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

Show key headers only | View raw


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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-06 15:11 -0700
  Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Dave Angel <davea@davea.name> - 2015-05-06 20:58 -0400
  Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 12:19 +1000
    Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-05-07 13:33 +1000
      Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 13:57 +1000
      Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Gisle Vanem <gvanem@yahoo.no> - 2015-05-07 09:15 +0200
        Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 02:38 -0700
          Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 03:03 -0700
            Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 13:10 +0300
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 20:24 +1000
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Dave Angel <davea@davea.name> - 2015-05-07 07:28 -0400
              Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 21:43 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 15:41 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-07 22:53 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 16:44 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 00:03 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 18:24 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 08:45 -0700
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-07 21:13 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Stefan Zimmermann <zimmermann.code@gmail.com> - 2015-05-07 16:27 -0700
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 11:50 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Ben Finney <ben+python@benfinney.id.au> - 2015-05-08 12:26 +1000
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Marko Rauhamaa <marko@pacujo.net> - 2015-05-08 09:14 +0300
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Ian Kelly <ian.g.kelly@gmail.com> - 2015-05-07 09:14 -0600
                Re: PEP idea: On Windows, subprocess should implicitly support .bat and .cmd scripts by using FindExecutable from win32 API Chris Angelico <rosuav@gmail.com> - 2015-05-08 11:46 +1000

csiph-web