Reply
 
Thread Tools Display Modes
  #1  
Old 06-28-2006, 08:20 PM
krreagan krreagan is offline
Member
 
Join Date: Mar 2006
Location: Colorado, USA
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default Cannot run bash script???
Okay,

I have been running a bash script under FBSD for several years without a problem. I just installed PC-BSD and installed the Bash PBI. Now the interpreter does not recognize the script as a bash script?

Simplified script example.
Code:
#!/bin/bash
declare PROGRAM="Hello world"
printf "Hi and %s\n" $PROGRAM
The execute bit is set.
The ~/bin directory (location of script) is in my PATH.
"which" command reports /bin/bash.

Now when I execute:
>hw
declare: Command not found.
PROGRAM: Undefined variable.

when I execute:
>/bin/bash hw
Hi and Hello World

is correct?!?!?!

Any Ideas why the interpreter is not using bash with the shabang line?

On a side note! Please Please Please include the man pages with bpi's like bash! (command line utilities) This was one of my pet-peves with linux! FBSD seemed to always include the man pages and that was wonderful!

Thanks
Krreagan
Reply With Quote
  #2  
Old 06-28-2006, 10:16 PM
TerryP TerryP is offline
Senior Member
 
Join Date: Nov 2005
Location: Ga. USofA
Posts: 7,906
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to TerryP Send a message via AIM to TerryP Send a message via Yahoo to TerryP
Default
try changing the shabang to
!#/usr/local/bin/bash

/bin would only contains sh, csh, and tcsh as that is what is in the installation.

Also I'm not sure if the Bash PBI updates the /etc/shells file, I havn't used it since it was a new PBI hehe.
Reply With Quote
  #3  
Old 06-28-2006, 10:31 PM
Charles Charles is offline
Senior Member
 
Join Date: May 2005
Posts: 3,710
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Mmmh... This is bad. Any shell script looks for /bin/sh or /bin/bash for instance.
Reply With Quote
  #4  
Old 06-29-2006, 12:01 AM
krreagan krreagan is offline
Member
 
Join Date: Mar 2006
Location: Colorado, USA
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Originally Posted by TerryP
try changing the shabang to
!#/usr/local/bin/bash

/bin would only contains sh, csh, and tcsh as that is what is in the installation.

Also I'm not sure if the Bash PBI updates the /etc/shells file, I havn't used it since it was a new PBI hehe.
The /usr/local/bin/bash shebang line change did not work and you are correct the PBI did not update the /etc/shells file. I did this manually but (of course) it didn't have any affect on running the scripts.

I have also repeated this behavior on my home system (where I am now), so this is a repeatable issue. Again, if I explicitly execute the script with the shell (ie. >/bin/bash script_to_execute) all works as expected.

Krreagan
Reply With Quote
  #5  
Old 06-29-2006, 12:24 AM
TerryP TerryP is offline
Senior Member
 
Join Date: Nov 2005
Location: Ga. USofA
Posts: 7,906
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to TerryP Send a message via AIM to TerryP Send a message via Yahoo to TerryP
Default
Ballocks I just relized I wrote !# instead of #! it's been that long since I've done shell scripting....

ok two ideas.

#ln -s /usr/local/bin/bash /bin/bash
which would not work on other systems. I or someone else could try to repack the bash PBI and fix it to do that and update /etc/shells later.

Another idea would be to use #!/bin/sh from which bash was derived if your not using bash specific's.

Mmmmmm.

PS: as bash is really in /Programs/bash-x.y.n it should not be used as the root users shell: Same for any shell not in /bin or /sbin I believe.
Reply With Quote
  #6  
Old 06-29-2006, 02:44 PM
krreagan krreagan is offline
Member
 
Join Date: Mar 2006
Location: Colorado, USA
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default
Wow! I just followed the existing links for bash and here is what I found...

Code:
 [101] > ll /bin/bash
lrwxr-xr-x  1 root  wheel  19 Jun 28 11:07 /bin/bash@ -> /usr/local/bin/bash
[102] > ll /usr/local/bin/bash
lrwxr-xr-x  1 root  wheel  32 Jun 28 11:07 /usr/local/bin/bash@ -> /usr/local/MyPrograms/.sbin/bash
[103] > ll /usr/local/MyPrograms/.sbin/bash
-rwxr-xr-x  1 root  wheel  217 Jun 28 11:07 /usr/local/MyPrograms/.sbin/bash*
[104] > cat /usr/local/MyPrograms/.sbin/bash
#!/bin/sh
# Auto-Generated by PC-BSD
PATH="/usr/local/MyPrograms/Bash3.0/bin:$PATH"; export PATH
LD_LIBRARY_PATH="/usr/local/MyPrograms/Bash3.0/libs//" ; export LD_LIBRARY_PATH
/usr/local/MyPrograms/Bash3.0/bash "$@"
[105] >
Is this the normal configuration for programs in PC-BSD? This looks like a cluster #$&^ to me if it is.

I understand the need for the .../.sbin/bash shell script for the library setup so that everything is self contained... but the link from /bin/bash to /usr/local/bin/bash is unnecessary and IMHO, should be changed to something like:
ln -s /bin/bash /usr/local/MyPrograms/.sbin/bash

My $.02
Krreagan
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Using BASH as default gnutux FreeBSD Help 1 08-15-2006 11:27 PM
getting a bash script to run koen FreeBSD Help 10 03-01-2006 12:02 PM
BASH to SH Almindor Creating PC-BSD Packages (.pbi files) 6 12-20-2005 10:08 PM
Bash default? Charles Feature Requests 10 10-21-2005 09:27 AM
bash.pbi doesn't add it to /etc/shells scottro General Bug Reports 0 06-08-2005 11:22 PM


All times are GMT. The time now is 01:47 PM.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.

Copyright 2005-2010, The PC-BSD Project. PC-BSD and the PC-BSD logo are registered trademarks of iXsystems.
All other content is freely available for sharing under the terms of the Creative Commons Attribution License.