bash error that isn't?
Web Server forum
Back To The Forum Home!Search!Private Messaging System

Web Server Talk Web Server Talk > Unix and Linux reviews > Free Debian support > Linux Debian support > bash error that isn't?




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    bash error that isn't?  
Dave Murray


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-14-07 12:12 AM

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





[ Post a follow-up to this message ]



    Re: bash error that isn't?  
Lew Pitcher


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-14-07 12:12 AM

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. Th
e
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.          ------






[ Post a follow-up to this message ]



    Re: bash error that isn't?  
Dave Murray


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
08-14-07 06: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 f
ar
> 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 for
m)
> 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





[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 10:38 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 
Medical and Health forum | Computer Games Reviews | Graphics design forum

Back To The Top
Home | Usercp | Faq | Register