# Cannot run bash script file



## AlexF (Mar 23, 2010)

FreeBSD 8.0:


```
# 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


----------



## Ico (Mar 23, 2010)

```
#which bash
/usr/local/bin/bash
```


----------



## graudeejs (Mar 23, 2010)

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


----------



## AlexF (Mar 23, 2010)

New information: I can run this script by typing:
/usr/local/bin/bash ./configure

I just need to activate bash properly.


----------



## SirDice (Mar 23, 2010)

AlexF said:
			
		

> ```
> # usr/local/bin/bash
> 
> {snip}
> ...


You could use your brain for a second. You typed the answer yourself at the top :e


----------



## AlexF (Mar 23, 2010)

which bash gives:
/usr/local/bin/bash

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


----------



## SirDice (Mar 23, 2010)

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.


----------



## AlexF (Mar 23, 2010)

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.


----------



## SirDice (Mar 23, 2010)

No, you need to modify each and every script.


----------



## graudeejs (Mar 23, 2010)

you can do this PORN way

```
$ 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


----------



## phoenix (Mar 23, 2010)

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.


----------



## graudeejs (Mar 23, 2010)

The root cause of the problem is that Linux use BASH


----------



## AlexF (Mar 24, 2010)

Thank you, got it working.


----------

