Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 Sep 2002 17:13:02 +0300
From:      Giorgos Keramidas <keramida@ceid.upatras.gr>
To:        Kirk Bailey <idiot1@netzero.net>
Cc:        "freebsd-questions@freebsd.org" <freebsd-questions@FreeBSD.org>
Subject:   Re: sh script question
Message-ID:  <20020903141301.GN17303@hades.hell.gr>
In-Reply-To: <3D743DFF.B1DE6C8A@netzero.net>
References:  <3D743DFF.B1DE6C8A@netzero.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 2002-09-03 00:43 +0000, Kirk Bailey wrote:
> I want to write a script to install a python application. I has to locate the
> interpreter, extract that path, and create the shebang declaration on the first
> line, then append the remaining prepared script to that ...

You don't need to do all that to 'detect' where python is.  The python
documentation at www.python.org suggests using the following for your
own scripts:

: $ ls -l koko.py
: -rwxrwxr-x  1 charon  charon  - 44 Sep  3 17:11 koko.py*
: $ cat koko.py
: #!/usr/bin/env python
:
: print "Hey, there!";
: $ ./koko.py
: Hey, there!

This way, env(1) is the intepreter, and python will be searched in the
PATH the usual way.  Then it won't matter if it's /usr/bin/python,
/usr/local/bin/python, or even /opt/python/bin/python, as long as the
proper directory is part of PATH.

-- 
FreeBSD: The Power to Serve -- http://www.FreeBSD.org

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020903141301.GN17303>