* bash scripting
@ 2004-08-15 3:00 dave
0 siblings, 0 replies; 7+ messages in thread
From: dave @ 2004-08-15 3:00 UTC (permalink / raw)
To: linux-newbie
I tried the same script with #!/bin/bash as the first line and get the
same error. Then I cd to /bin and do a ls bash and this is what I get.
[dave@dave bin]$ ls bash
bash*
[dave@dave bin]$ ./bash
[dave@dave bin]$ /home/dave/scripts/new.sh
: bad interpreter: No such file or directory
[dave@dave bin]$
Then I tried the samw script again and I get the same error. I used
chmod and set the script file as 777. Still no go. I believe its not
finding bash but I sure can't tell why. I ran a setup.sh script in
/usr/share/webmin today and it ran just fine. I am confused Any more
ideas? Thanks again.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* bash scripting
@ 2004-08-15 3:12 dave
0 siblings, 0 replies; 7+ messages in thread
From: dave @ 2004-08-15 3:12 UTC (permalink / raw)
To: linux-newbie
Well I got it to run. I browsed the web a bit and found this command
cat -v new.sh. That showed lots of ^M at the end of each line. Then I
used :set ff=unix to set the file format for unix. It works now. I
don't know how the ^M's got in the file. I wrote it on my linux box.
Thanks everyone for the help.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* bash scripting
@ 2004-08-14 20:35 dave
2004-08-14 21:31 ` John Kelly
2004-08-14 23:13 ` Ray Olszewski
0 siblings, 2 replies; 7+ messages in thread
From: dave @ 2004-08-14 20:35 UTC (permalink / raw)
To: linux-newbie
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: bash scripting
2004-08-14 20:35 dave
@ 2004-08-14 21:31 ` John Kelly
2004-08-14 23:13 ` Ray Olszewski
1 sibling, 0 replies; 7+ messages in thread
From: John Kelly @ 2004-08-14 21:31 UTC (permalink / raw)
To: linux-newbie
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 <dave@dpomeroy.com> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: bash scripting
2004-08-14 20:35 dave
2004-08-14 21:31 ` John Kelly
@ 2004-08-14 23:13 ` Ray Olszewski
1 sibling, 0 replies; 7+ messages in thread
From: Ray Olszewski @ 2004-08-14 23:13 UTC (permalink / raw)
To: linux-newbie
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* bash scripting
@ 2004-08-14 6:35 dave
2004-08-14 12:36 ` John Kelly
0 siblings, 1 reply; 7+ messages in thread
From: dave @ 2004-08-14 6:35 UTC (permalink / raw)
To: linux-newbie
I wrote the following script to learn to read and write files. No matter how I
try to start it it doesn't work.
#!/bin/bash
shopt -s -o nounset
declare LINE
exec 3< test.dat
while read LINE <&3 ; do
printf "%s\n" "$LINE"
done
exit 0
this is the error
[root@localhost scripts]# ./test.sh
: bad interpreter: No such file or directory
[root@localhost scripts]#
can someone point me in the write direction? thanks again
Dave
-
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: bash scripting
2004-08-14 6:35 dave
@ 2004-08-14 12:36 ` John Kelly
0 siblings, 0 replies; 7+ messages in thread
From: John Kelly @ 2004-08-14 12:36 UTC (permalink / raw)
To: linux-newbie
Hi,
On Fri, 13 Aug 2004 23:35:14 -0700
"" <dave@dpomeroy.com> wrote:
>
>
> I wrote the following script to learn to read and write files. No
> matter how I try to start it it doesn't work.
>
> #!/bin/bash
>
> shopt -s -o nounset
>
> declare LINE
>
> exec 3< test.dat
>
> while read LINE <&3 ; do
> printf "%s\n" "$LINE"
> done
>
> exit 0
>
I copied this into a file and it runs fine on my Debian system. I
think your error message gives a hint.
> this is the error
>
> [root@localhost scripts]# ./test.sh
> : bad interpreter: No such file or directory
> [root@localhost scripts]#
>
: bad interpreter: No such file or directory
Usually means that the system can't find the interpreter. ie when it
looks at the line:#!/bin/bash
it can't find /bin/bash.
I have seen similiar problems with perl. Someone puts
#!/bin/perl
in a script. It works on one machine but if the script is moved to
another machine, it bombs out because the perl interpreter is in a
different place.
I assume bash is on your system. Try running
which bash
to find the path to the bash excutable. On most Linux systems it is
/bin/bash but I have seen /usr/local/bin/bash and /opt/bin/bash (on a
Solaris system).
Incidently, my standard way of writing scripts in vi is to type
#!
Then type <ESC>
Then type : r ! which bash
This causes the path to bash appear on the line under the #! line.
I then move the cursor up one line and type J to join the lines.
This guarantees the correct path to the interpreter on the machine I
am using. But then you may not be using vi :-)
Hope this helps.
regards,
John Kelly
-
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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2004-08-15 3:12 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-15 3:00 bash scripting dave
-- strict thread matches above, loose matches on Subject: below --
2004-08-15 3:12 dave
2004-08-14 20:35 dave
2004-08-14 21:31 ` John Kelly
2004-08-14 23:13 ` Ray Olszewski
2004-08-14 6:35 dave
2004-08-14 12:36 ` John Kelly
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox