Results 1 to 7 of 7
Enjoy an ad free experience by logging in. Not a member yet? Register.
If I am in the Bash shell, why would my script not run unless preceded by /bin/bash?
When I do "set" to list my variables it says:
Yet if I make the script executable and do not precede it with /bin/bash - Bash tells me "command not found".
Not real important, just curious.
I am learning from a book, by the way.
Bash version is 3.2.39(1)release
Because there are a lot of script languages: php, perl, python, various shells, etc.
The Shebang tells the program loader, which interpreter to load, which in turn is given the script to execute.
Little trick to gain portability:
Last edited by Irithori; 09-11-2011 at 09:10 PM.You must always face the curtain with a bow.
Got it. I did read that, but did not digest it. Thanks.
Ok.Nothing works but /bin/bash in front of the executable name. The cheat code in the script does not work.
For now I will execute the script preceded by /bin/bash. I know the shells are standardized, bit confusing why I cannot put it in the script. Either the referenced material or your cheat.
I am Debian. Script created in Vi.
Can you please paste the shebang of your script in Code tags?
The head should look similar this:
vi first_script.sh write this and save: #!/bin/env bash echo "first script" chmod 750 first_script.sh ./first_sript.shYou must always face the curtain with a bow.
Thanks. I was not using the . /
When using . / I was able to run it with #!/bin/sh as first line. But not #!/bin/env bash "/bin/env - bad interpreter".
I can either use /bin/bash before the executable. Or #!/bin/sh and . /
My first lesson was success. Putting the book away for now. Thanks for your assist. Thanks for the chmod cheat, too.
Oops, should have been
#!/usr/bin/env bashYou must always face the curtain with a bow.