Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 7 Jan 2008 11:00:32 -0500
From:      "Josh Carroll" <josh.carroll@gmail.com>
To:        stevefranks@ieee.org
Cc:        User Questions <freebsd-questions@freebsd.org>
Subject:   Re: home dir executable (!/bin/sh, chmod+x) shell scripts won't run without "sh <script>"
Message-ID:  <8cb6106e0801070800u24ed481dlce6eb0077c6facea@mail.gmail.com>
In-Reply-To: <539c60b90801070752l3d0e571cq8f7b1b519e1e808c@mail.gmail.com>
References:  <539c60b90801070752l3d0e571cq8f7b1b519e1e808c@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
> I keep reading about making sh scripts executable with #!/bin/sh on
> the first line and chmod to executable.  That works with all my system
> scripts (rc, etc.) or my system would be DOA, no doubt.  When I do it
> in my home folder, however, running <script> gives "command not
> found".

That typically indicates the path you've specified in the sh-bang does
not exist. Another common problem there is if the shell script was
written out in DOS format.

If you're certain the first line looks proper, and that the path
exists (/bin/sh most certainly should), try:

perl -p -i -e 's/\r\n/\n/' foo.sh

Then see if it works.

> scripts executable, they all say the same thing, and they all don't
> work.  How did I get to be so special?

It's possible the partition /home is mounted on is mounted with
noexec, but in that case, I'd expect you'd get a "permission denied"
message, rather than "command not found".

Josh



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