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


Groups > comp.lang.python > #29588

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

Path csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!feeds.phibee-telecom.net!dedekind.zen.co.uk!zen.net.uk!hamilton.zen.co.uk!reader01.nrc01.news.zen.net.uk.POSTED!not-for-mail
From Nobody <nobody@nowhere.com>
Subject Re: portable way of locating an executable (like which)
Date Fri, 21 Sep 2012 00:59:53 +0100
User-Agent Pan/0.14.2 (This is not a psychotic episode. It's a cleansing moment of clarity.)
Message-Id <pan.2012.09.20.23.59.52.522000@nowhere.com>
Newsgroups comp.lang.python
References <mailman.973.1348175220.27098.python-list@python.org>
MIME-Version 1.0
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 8bit
Lines 21
Organization Zen Internet
NNTP-Posting-Host 3f40277c.news.zen.co.uk
X-Trace DXC=MSc<i^c6kGm1PHEoBToc[da0UP_O8AJol=dR0\ckLKG`WeZ<[7LZNRf1<`:M]jF@HbM2Z^cWRFGAkf>I6hkWndVi
X-Complaints-To abuse@zen.co.uk
Xref csiph.com comp.lang.python:29588

Show key headers only | View raw


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).

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