Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 20 Oct 1997 17:59:17 -0700 (PDT)
From:      Donald Burr <dburr@POBoxes.com>
To:        questions@FreeBSD.ORG
Cc:        jcwells@u.washington.edu
Subject:   RE: questions-digest V3 #489
Message-ID:  <XFMail.971020180117.dburr@POBoxes.com>
In-Reply-To: <199710202356.QAA29920@hub.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----

My secret spy satellite informs me that on 20-Oct-97,
owner-questions-digest@FreeBSD.ORG wrote:

>From: Jason Wells <jcwells@u.washington.edu>
>Date: Mon, 20 Oct 1997 20:44:50 +0000
>Subject: Force a script to use shell foo
>
>Lets say I run a script from cron. There is no shell to inherit. The
>script
>would use /bin/sh. But silly me, I wrote my program to use bash.
>
>Is it sufficient to just enter the command /usr/local/bin/bash within the
>script to get the script to use bash? If not, how do I set up an
>environment for a program?

The proper way of doing this is to include the following line as the VERY
FIRST LINE In your script:

#!/path/to/shell

For example, to run a shell script using tcsh, which is located in
/usr/local/bin, you would place:

#!/usr/local/bin/tcsh

as the first line.

Note that you can also use this with other types of interpreted languages,
e.g. PERL.  if you have a PERL script you want to be able to execute by
just giving its name (to be able to type "foo" instead of "perl foo" at
the cmdline), add

#!/usr/local/bin/perl

(or /usr/bin/perl, etc.) as its first line.

Be sure the file is executable!  (chmod +x filename)

- ---
Donald Burr <dburr@POBoxes.com> - Ask me for my PGP key | PGP: Your
WWW HomePage: http://DonaldBurr.base.org/  ICQ #1347455 | right to
Address: P.O. Box 91212, Santa Barbara, CA 93190-1212   | 'Net privacy.
Phone: (805) 957-9666    FAX: (800) 492-5954            | USE IT.

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2

iQCVAwUBNEv+3PjpixuAwagxAQGz9AP9FAzW85iX3EiuKJa27MEfgpDv6UAW7qI7
+fPd7RqEY+imcjaBLTZ1sTEDkUSJ8UJw2onVGgCz0yGQb7OhMRa1QdDmyXdbrRCQ
timroJd1GHDs532sZMhEXyVIBEy3nN+qrA86DBxPEItzASXQme9H20272v1H9Czj
vEiK5PtBehU=
=au9H
-----END PGP SIGNATURE-----



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