Cannot run bash script file

FreeBSD 8.0:

Code:
# usr/local/bin/bash

[root@ /home/alex/package/six-package]# ls

configure

[root@ /home/alex/package/six-package]# file configure

configure: Bourne-Again shell script text executable

[root@ /home/alex/package/six-package]# ./configure

bash: ./configure: /bin/bash: bad interpreter: No such file or directory

Why this script is not executed? Script is tested under Ubuntu OS, starts with:
#!/bin/bash
 
Because this is FreeBSD, we don't fallow stupid linuxism like /bin/bash which is not portable and in fact is non-standard

either change #!/bin/bash to #!/bin/sh or install bach from ports and change to #!/usr/local/bin/bash
 
New information: I can run this script by typing:
/usr/local/bin/bash ./configure

I just need to activate bash properly.
 
AlexF said:
Code:
# usr/local/bin/bash

{snip}

bash: ./configure: /bin/bash: bad interpreter: No such file or directory

Why this script is not executed?
You could use your brain for a second. You typed the answer yourself at the top :e
 
which bash gives:
/usr/local/bin/bash

bash ./configure is working for me. That's fine. Is it possible to activate bash by default?
 
AlexF said:
which bash gives:
/usr/local/bin/bash

bash ./configure is working for me. That's fine. Is it possible to activate bash by default?

It is activated by default. It's the script that needs to be modified.
 
configure script calls another scripts, each call gives the same error: bad interpreter. I need to have bash as current shell. How to do this?
Thank you.
 
you can do this PORN way
Code:
$ ln -s /usr/local/bin/bash /bin/bash

But it's porn, it sux, and nobody should ever do this


If you are porting software to FreeBSD, then this is absolutely unacceptable
 
The root cause of the problem is that BASH gets installed as /bin/bash on Linux systems, and as /usr/local/bin/bash on FreeBSD systems.

Because of this, BASH scripts that are written on Linux systems have #!/bin/bash at the top, which tells the current shell to execute this script using ... /bin/bash ... which doesn't exist on a FreeBSD system.

The simple solution is to modify the first line of each BASH script to use #!/usr/local/bin/bash

The correct solution is to re-write the scripts to use portable Bourne Shell instead of non-portable/non-standard BASH. IOW, use #!/bin/sh which exists on every UNIX-like/POSIX-compliant OS.
 
Back
Top