Where is bash?


#1

Hi there,

I have moved around some of the files in my home area. I am now trying to execute a bash script but I don’t know what to put as the she-bang, what should it be? I thought

#!/usr/bin/env bash

but i no longer have a bin directory in my home path, i moved it to sw/bin and there is no env directory - what should i do?


#2

#!/bin/bash

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#3

Yes, but I have moved or deleted bash so when bash tries to execute:

#!/bin/bash

it returns:

-bash: /home/morgwaan/sw/bin/time2: /bin/bash^M: bad interpreter: No such file or directory


#4

You can’t “remove” /bin/bash persay.

$ which bash should return your currently useable path. Look in .bash_profile to see if it’s overwriting too much.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost


#5

It looks like you wrote the script in Windows, so it tacked a CTRL M on the end. Run dos2unix on the script to strip those off.

[quote]dos2unix myscript.sh

[/quote]

-Scott


#6

Cheers man, that was pretty stupid of me.

So, what is actually happening when I specify #!/bin/bash is it looking in the Dreamhost server route for bash?

Thanks for all your help!


#7

#! tells the script in which mode (shell) to run. All shells, such as bash, are part of the Linux installation on the server. It’s really just another UNIX command.

-Scott


#8

Take a closer to the error message you previously posted here.
The error suggests that ‘/bin/bash^M’ was not found.

The end-of-line sequence of Linux systems is ‘^J’@(CTRL-J),
while Windows prefer ‘^M^J’.
So you got rid of trailing ‘^M’s by dos2unix in order to use
’/bin/bash’ instead of ‘/bin/bash^M’.


#9

Excellent idea! Where have I seen that before?

-Scott


#10

hmm, what are you talking about?
You teached him how-to, and then he wanted to know why.


#11

Nah, he wanted to know what the #!/bin/bash header did.

Maximum Cash Discount on any plan with MAXCASH

How To Install PHP.INI / ionCube on DreamHost