Re: How to setup a simple shell script? "bad interpreter: No suchfile or directorybin/bash"

Re: How to setup a simple shell script? "bad interpreter: No suchfile or directorybin/bash"

am 27.12.2007 12:12:43 von artix

Matthew Lincoln wrote:
> I wanted to setup a simple shell script "test3" with some commands inside.
>
> I started the script with
>
> #!/bin/bash
> ....
>
> When I call the script I got the error:
>
> : bad interpreter: No such file or directorybin/bash
>
> Hmm, why is there no such file ?
>
> If I type at the shell:
>
> echo $SHELL
>
> then I got the reply:
>
> /bin/bash
>
> Moreover /bin/bash exists!!
>
> So how do I setup a shell script otherwise?
>
> Am I forced to append a ".sh" extension?

no need for the .sh extension.

I can think of two issues causing this:

1) try delimiting your shebang with a space, so it will look like this:

#! /bin/bash

Not sure why, but this helps sometimes.

2) make sure the editor you use to write shell scripts is set to use
Unix end of line and not DOS/Windows. DOS/Windows uses two characters:
CR and LF ("carriage return", "line feed") to mark end of line in a text
file. Unix text files end with an LF ("line-feed") only. To remove the CR:

tr -d '\r' < dosfile > unixfile

--
artix
http://www.abstractart.ws _Abstract Art Directory_

Re: How to setup a simple shell script? "bad interpreter: No such file or directorybin/bash&quo

am 28.12.2007 02:22:24 von Sven Mascheck

artix wrote:

> 1) try delimiting your shebang with a space, so it will look like this:
>
> #! /bin/bash

Have you ever experienced this yourself?

Re: How to setup a simple shell script? "bad interpreter: No suchfile or directorybin/bash"

am 28.12.2007 14:06:29 von artix

Sven Mascheck wrote:
> artix wrote:
>
>> 1) try delimiting your shebang with a space, so it will look like this:
>>
>> #! /bin/bash
>
> Have you ever experienced this yourself?

I'm quite sure I did, on a few rare occasions though.

--
artix
http://www.abstractart.ws _Abstract Art Directory_

Re: How to setup a simple shell script? "bad interpreter: No such file or directorybin/bash&quo

am 28.12.2007 14:44:42 von Sven Mascheck

artix wrote:

> I'm quite sure I did, on a few rare occasions though.

It's only useful if reproducable. On which system?

Re: How to setup a simple shell script? "bad interpreter: No suchfile or directorybin/bash"

am 29.12.2007 05:29:00 von artix

Sven Mascheck wrote:
> artix wrote:
>
>> I'm quite sure I did, on a few rare occasions though.
>
> It's only useful if reproducable. On which system?

Sorry I don't remember other than it was Linux and that it was at least
several years ago. It was on one of the following systems that I used
over the years: Red Hat, Mandrake, Suse, Slackware.

--
artix
http://www.abstractart.ws _Abstract Art Directory_

Re: How to setup a simple shell script? "bad interpreter: No such file or directorybin/bash&quo

am 29.12.2007 13:44:09 von Sven Mascheck

artix wrote:

> I don't remember other than it was Linux and that it was at least
> several years ago.

Then your problem was something different or your memory is fading
about this. Linux and other well known kernels (e.g. *BSD), for
which source is available, never had this issue.

(and a distributor couldn't have hacked his kernel without being
noticed, because so many system and installation scripts would
have had to be fixed - let alone: without any benefit at all.)

You can read that some early dynix variant (mid-80s) might
have shown this symptom, but apart from this i believe it's
a myth.
--
http://www.in-ulm.de/~mascheck/various/shebang/

Re: How to setup a simple shell script? "bad interpreter: No such file or directorybin/bash&quo

am 30.12.2007 04:55:23 von cdl

In article ,
Sven Mascheck wrote:
>artix wrote:
>
>> I don't remember other than it was Linux and that it was at least
>> several years ago.

>Then your problem was something different or your memory is fading
>about this. Linux and other well known kernels (e.g. *BSD), for
>which source is available, never had this issue.

I think you will find that the diagnostic
"bad interpreter: No such file or directory bin/bash"
can occur if the script is located in a file system that is mounted no-execute.

This happens infrequently, and the message is misleading, so it is hard
to track down.

carl
--
carl lowenstein marine physical lab, u.c. san diego
clowenstein@ucsd.edu