Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 1 Dec 2005 13:22:43 -0600
From:      Will Maier <willmaier@ml1.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: Can't run scripts no more: "permission denied"
Message-ID:  <20051201192243.GG10377@merkur.atekomi.net>
In-Reply-To: <20051201194850.42578863.blue.raccoon@wanadoo.nl>
References:  <20051201173603.3E9EC16A427@hub.freebsd.org> <20051201185956.ee767f97.blue.raccoon@wanadoo.nl> <20051201181512.GA63703@flame.pc> <20051201194850.42578863.blue.raccoon@wanadoo.nl>

next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Dec 01, 2005 at 07:48:50PM +0100, Blue Raccoon wrote:
> On Thu, 1 Dec 2005 20:15:12 +0200
> But the 'sylpheed' script still would not run: "command not
> found". There is only one command in the file (which works fine on
> the command line) and a comment: #!/bin/bash I copied the script
> from the web. But apparently the comment is not a comment. When I
> remove it the script works (not from firefox, but that's a
> different problem).

That's not a (regular) comment, it's called 'sh-bang'. It tells the
shell which command should be used to interpret the following code.
For example, perl scripts usually start with
    
    #!/usr/bin/perl -w

Which tells whatever shell you're running (like bash) to start perl
as the interpreter for that script.

In your case, you were trying to tell the shell to use bash as the
interpreter. This is fine, as long as you have bash installed (it's
not part of the FreeBSD base system). Moreover, you need to specify
the correct path to the bash executable in your sh-bang. On FreeBSD,
bash is usually installed via a port or package to /usr/local/bin. A
better way of fixing your script (instead of just removing the
sh-bang altogether) would be to edit it to read as follows:
    
    #!/bin/sh

That'll point to FreeBSD's sh implementation, which is the standard
Unix shell. Some Linuxes will use bash as their sh, but most BSDs
use a more standard sh. Writing shell scripts for sh (and not bash,
ksh or whatever) is a good idea as it will make your scripts easier
to port to other systems. bash is similar to sh, so you might not
need to change anything (unless you're using lots of bashisms or
arrays or whatnot).

-- 

o--------------------------{ Will Maier }--------------------------o
| jabber:..wcmaier@jabber.ccc.de | email:..........wcmaier@ml1.net |
| \.........wcmaier@cae.wisc.edu | \..........wcmaier@cae.wisc.edu |
*------------------[ BSD Unix: Live Free or Die ]------------------*



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