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


Groups > comp.lang.python > #29605

Re: portable way of locating an executable (like which)

Path csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!ecngs!feeder2.ecngs.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <tarek@ziade.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'algorithm': 0.03; 'paths': 0.05; 'alias': 0.07; 'emulate': 0.07; 'performs': 0.07; 'run,': 0.07; 'skip:/ 10': 0.07; 'aliases': 0.09; 'received:internal': 0.09; 'sep': 0.09; 'windows,': 0.09; 'programs.': 0.11; 'extensions': 0.13; 'from:name:tarek ziad\xe9': 0.16; 'omitted,': 0.16; 'program"': 0.16; 'received:10.202': 0.16; 'received:10.202.2': 0.16; 'received:66.111': 0.16; 'received:66.111.4': 0.16; 'received:mail.srv.osa': 0.16; 'received:messagingengine.com': 0.16; 'received:nyi.mail.srv.osa': 0.16; 'received:osa': 0.16; 'received:srv.osa': 0.16; 'subject:which': 0.16; 'wrote:': 0.17; 'skip': 0.17; 'thu,': 0.17; 'shell': 0.18; 'equivalent': 0.20; 'commands,': 0.22; 'precise': 0.22; "i'd": 0.22; 'linux': 0.24; 'command': 0.24; 'host': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; '(e.g.': 0.27; 'am,': 0.27; 'wonder': 0.27; 'behaviour': 0.29; 'subject:like': 0.29; 'function': 0.30; 'implement': 0.32; 'url:python': 0.32; '+0200,': 0.33; 'interface,': 0.33; 'to:addr :python-list': 0.33; 'built-in': 0.35; 'similar': 0.35; 'explain': 0.36; 'but': 0.36; 'url:org': 0.36; 'should': 0.36; 'subject: (': 0.36; 'execute': 0.37; 'why': 0.37; 'systems,': 0.37; 'subject:: ': 0.38; 'files': 0.38; 'some': 0.38; 'received:10': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'different': 0.63; 'gelonida': 0.84; 'subtly': 0.84; 'url:cpython': 0.84
DKIM-Signature v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=message-id:date:from:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; s=smtpout; bh=R5CKS5toYS43KD6waESQpY lwgZk=; b=ZXx9TrADtbUpYSljTzUOTyb9XRJsPBItrDtPW2BxMIF3hKYDSbRsiN uzFoV1PDdPinAP/BDgB/PmkZgftM7Kqb1GTGrut0MjqNhjPnIUuDafJdVbtIUiCH bNPVSukjW69VNl0GJ682Yrf5JmWojeA3KiRS+NWUQW/yRkfR4PKJM=
X-Sasl-enc j8bcdWWqFOq2DK+fqZw4gswrnwcq2a+UZvcO0S6Iw9G6 1348215118
Date Fri, 21 Sep 2012 10:12:29 +0200
From Tarek Ziadé <tarek@ziade.org>
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:15.0) Gecko/20120907 Thunderbird/15.0.1
MIME-Version 1.0
To python-list@python.org
Subject Re: portable way of locating an executable (like which)
References <mailman.973.1348175220.27098.python-list@python.org> <pan.2012.09.20.23.59.52.522000@nowhere.com>
In-Reply-To <pan.2012.09.20.23.59.52.522000@nowhere.com>
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.991.1348215490.27098.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1348215490 news.xs4all.nl 6886 [2001:888:2000:d::a6]:45892
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:29605

Show key headers only | View raw


On 9/21/12 1:59 AM, Nobody wrote:
> On Thu, 20 Sep 2012 23:06:46 +0200, Gelonida N wrote:
>
>> I'd like to implement the equivalent functionality of the unix command
>> /usr/bin/which
>>
>> The function should work under Linux and under windows.
> Note that "which" attempts to emulate the behaviour of execvp() etc. The
> exec(3) manpage will explain the precise algorithm used (e.g. they skip
> files for which the process lacks execute permission).
>
> Also, note that the shell has built-in commands, functions, and aliases in
> addition to programs. The "type" built-in command performs a similar
> function to "which" but using the shell's semantics. On some systems,
> the default configuration may alias "which" to "type".
>
> On Windows, there's a host of different "execute program" interface, all
> with subtly different semantics: which extensions they will run, which
> extensions can be omitted, which paths are used (e.g. %PATH%, paths
> from the registry, current directory).
>
You can also look at shutil.which

http://hg.python.org/cpython/file/aa153b827d17/Lib/shutil.py#l974


Mmmm I wonder why it's removed in the last revs..

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


Thread

portable way of locating an executable (like which) Gelonida N <gelonida@gmail.com> - 2012-09-20 23:06 +0200
  Re: portable way of locating an executable (like which) Nobody <nobody@nowhere.com> - 2012-09-21 00:59 +0100
    Re: portable way of locating an executable (like which) Tarek Ziadé <tarek@ziade.org> - 2012-09-21 10:12 +0200
  Re: portable way of locating an executable (like which) Ramchandra Apte <maniandram01@gmail.com> - 2012-09-22 20:55 -0700
  Re: portable way of locating an executable (like which) Ramchandra Apte <maniandram01@gmail.com> - 2012-09-22 20:55 -0700

csiph-web