Results 1 to 7 of 7
Greetings I have a general question. I just began my first lesson in Bash programming. If I am in the Bash shell, why would my script not run unless preceded ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 09-11-2011 #1
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
- 09-11-2011 #2
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.
- 09-11-2011 #3
Got it. I did read that, but did not digest it. Thanks.
- 09-11-2011 #4
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.
- 09-11-2011 #5
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.
- 09-11-2011 #6
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.
- 09-11-2011 #7
Oops, should have been
#!/usr/bin/env bashYou must always face the curtain with a bow.