[Tutor] shebang question

زياد بن عبدالعزيز البا زياد بن عبدالعزيز البا
Sun Nov 26 09:01:55 CET 2006


"john maclean" <jayeola at gmail.com> On Sun, 26 Nov 2006 01:34:28 +0000
wrote:
> From what I can tell/remember, the first works in the *nix environment
> if python is in your $PATH, ...
Actually, no.  The first will try to feed the script to the executable
"/usr/bin/python".  If that doesn't exist (or is not executable) it'll
fail.

> ...the latter will find python "somehere" on your system by looking at
> wher the executables should be.
True, assuming there's "/usr/bin/env" on your system (and is executable)
and that "python" is found in your "$PATH" (and is executable).


The problem is that Python is not installed in the same place on all
OSes!  Some will install it under "/usr/local", others under "/opt".

The idea of "/usr/bin/env" is that it's always installed there (or it
should be!).  So, you don't need to figure out where is python (or perl,
ruby, make, sed, awk, or any other executable that "feeds" on
scripts/text files) installed as long as it's in your "$PATH".

(Of course, "env" have other uses.  As long as I can tell, this is not
the intended use of "env".  See "info env" for more information, or
if you don't have "info" see the manual.)

Ziyad.


More information about the Tutor mailing list