bash scripting

bash scripting

am 14.08.2004 22:35:41 von Dave Pomeory

OK I installed Mandrake 10 official and all things seem to be normal. I
still get the same message when I try to run a bash script.

#!/bin/env
bash


shopt -s -o nounset

declare LINE

exec 3< /home/dave/scripts/test.dat

while read LINE <&3 ; do
printf "%s\n" "$LINE"
done

exit 0

and here is the error message I get.

[dave@dave scripts]$ ./new.sh
: bad interpreter: No such file or directory
[dave@dave scripts]$

Anyone have any ideas. I used whereis bash and it returned /bin/bash.
Everything seems normal and I guess I'm over my head. Anyone with any
suggestions?

Thanks in advance.
Dave

--
Dave Pomeroy K7DNP SouthEastern Washington

-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: bash scripting

am 14.08.2004 23:31:51 von John Kelly

Hi,
I just tried to run the '#!/bin/env bash ' version of this script and
I
got:======================================================== =========
===== jpk@debian:~/scratch$ ./test.sh
bash: ./test.sh: /bin/env: bad interpreter: No such file or directory
============================================================ ==========
On my system env is in /usr/bin.
===================================
jpk@debian:~/scratch$ which env
/usr/bin/env
===================================
So this is essentially the same error as before - you are telling the
shell to run a program which is not where you say it is.

You can use the original version of the program and pass the correct
location of the bash interpreter to it. eg the first line should be
something like:#!/correct/path/to/bash
Of course the /correct/path/to/bash on my system is /bin/bash

Or use the later version and pass the correct location of env to it.
eg the first line should be something like:#!/correct/path/to/env bash
On my system the /correct/path/to/env is /usr/bin/env

Both of these work on my system.

Here's hoping I have not added to your confusion :-)

regards,

John Kelly

On Sat, 14 Aug 2004 12:35:41 -0800
dave wrote:

> OK I installed Mandrake 10 official and all things seem to be
> normal. I still get the same message when I try to run a bash
> script.
>
> #!/bin/env
> bash
>
>
> shopt -s -o nounset
>
> declare LINE
>
> exec 3< /home/dave/scripts/test.dat
>
> while read LINE <&3 ; do
> printf "%s\n" "$LINE"
> done
>
> exit 0
>
> and here is the error message I get.
>
> [dave@dave scripts]$ ./new.sh
> : bad interpreter: No such file or directory
> [dave@dave scripts]$
>
> Anyone have any ideas. I used whereis bash and it returned
> /bin/bash. Everything seems normal and I guess I'm over my head.
> Anyone with any suggestions?
>
> Thanks in advance.
> Dave
>
> --
> Dave Pomeroy K7DNP SouthEastern Washington
>
> -
> To unsubscribe from this list: send the line "unsubscribe
> linux-newbie" in the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.linux-learn.org/faqs
>
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs

Re: bash scripting

am 15.08.2004 01:13:51 von Ray Olszewski

At 12:35 PM 8/14/2004 -0800, dave wrote:
>OK I installed Mandrake 10 official and all things seem to be normal. I
>still get the same message when I try to run a bash script.
>
>#!/bin/env
>bash
>
>
>shopt -s -o nounset
>
>declare LINE
>
>exec 3< /home/dave/scripts/test.dat
>
>while read LINE <&3 ; do
> printf "%s\n" "$LINE"
>done
>
>exit 0
>
>and here is the error message I get.
>
>[dave@dave scripts]$ ./new.sh
>: bad interpreter: No such file or directory
>[dave@dave scripts]$
>
>Anyone have any ideas. I used whereis bash and it returned /bin/bash.
> Everything seems normal and I guess I'm over my head. Anyone with any
> suggestions?

You made two changes, not one. You both changed the distro install
("installed Mandrake 10") -AND- changed the shebang line in the script
("#!/bin/env"). The second change is definitely wrong.

Go back to the original shebang line ("#!/bin/bash") and see if it works
now. It does on my system (that is, I get errors, but they involve my not
having a file named /home/dave/scripts/test.dat).

Or make the first line (probably; check where "env' is on your system)
"#!/usr/bin/env bash". It too works here (up to the same error).

BTW, if I have the interpreter name wrong, I get a slightly different form
of error message from you (on a Debian-Sid install). Here, I changed "bash"
to "nash" and got this:

-bash: ./testscript.sh: /bin/nash: bad interpreter: No such file or directory

Not sure why you're not seeing all that stuff to the left of the ": bad
interpreter" part. Could just be a difference between your default shell
and mine (2.05b-19). Or it might indicate something odd about your script
that is not making it through a representation as e-mail.





-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs