|
Home > Archive > Linux Debian support > August 2007 > bash error that isn't?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
bash error that isn't?
|
|
| Dave Murray 2007-08-13, 7:12 pm |
| whereis shows that bash is at /bin/bash
me@myPlace:~$ whereis bash
bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
But when I run a script I get:
me@myPlace:~$ ./theScript
./theScript: line 1: !#/bin/bash: No such file or directory
--does everything correctly--
me@myPlace:~$
It all works, but why the "No such file or directory" message?
Dave
| |
| Lew Pitcher 2007-08-13, 7:12 pm |
| Dave Murray wrote:
> whereis shows that bash is at /bin/bash
>
> me@myPlace:~$ whereis bash
> bash: /bin/bash /etc/bash.bashrc /usr/share/man/man1/bash.1.gz
>
>
> But when I run a script I get:
>
> me@myPlace:~$ ./theScript
> ./theScript: line 1: !#/bin/bash: No such file or directory
> --does everything correctly--
> me@myPlace:~$
>
> It all works, but why the "No such file or directory" message?
Because, you got the line wrong :-)
The line /should/ read
#!/bin/bash
That's
hash (#)
bang (!)
/bin/bash
The hash (#) introduces a comment, making the rest of the line 'null' as far
as bash is concerned
OTOH, what you wrote
bang (!)
hash (#)
/bin/bash
started with a bang (!), which is a unary not operator for an expression. The
unary not /must/ be followed by an expression, which (in it's simplest form)
is the name of an executable.
! someprogram
would run
someprogram
and evaluate to a value of 0 if someprogram returned a non-zero value.
With your starting line, the shell tried to run the executable called
"#/bin/bash" (in order to logically NOT its resultcode) and could not find
that program. So, it reported back to you that there was no such file or
directory as "#/bin/bash"
--
Lew Pitcher
Master Codewright & JOAT-in-training | Registered Linux User #112576
http://pitcher.digitalfreehold.ca/ | GPG public key available by request
---------- Slackware - Because I know what I'm doing. ------
| |
| Dave Murray 2007-08-14, 1:13 am |
| Lew Pitcher wrote:
> Dave Murray wrote:
>
> Because, you got the line wrong :-)
>
> The line /should/ read
> #!/bin/bash
>
> That's
> hash (#)
> bang (!)
> /bin/bash
>
> The hash (#) introduces a comment, making the rest of the line 'null' as far
> as bash is concerned
>
> OTOH, what you wrote
> bang (!)
> hash (#)
> /bin/bash
>
> started with a bang (!), which is a unary not operator for an expression. The
> unary not /must/ be followed by an expression, which (in it's simplest form)
> is the name of an executable.
>
> ! someprogram
> would run
> someprogram
> and evaluate to a value of 0 if someprogram returned a non-zero value.
>
> With your starting line, the shell tried to run the executable called
> "#/bin/bash" (in order to logically NOT its resultcode) and could not find
> that program. So, it reported back to you that there was no such file or
> directory as "#/bin/bash"
Duh! Dyslexia strikes again. Thanks,
Dave
|
|
|
|
|