Tuesday, April 26, 2016

command: not found (declare: not found)


If you have any of these shebangs

Code:
#!/bin/sh
#!/bin/dash
#!/bin/bash
#!/bin/tcsh
#!/bin/zsh
#!/bin/awesome_shell
but you still call your code with
Code:
sh my_script.sh
the program effectively used will be "sh", and the shebang will be ignored.

You need to use the appropriate shell
Code:
sh   my_script.sh     # If the shebang is #!/bin/sh
dash my_script.sh     # If the shebang is #!/bin/dash
bash my_script.sh     # If the shebang is #!/bin/bash
tcsh my_script.sh     # If the shebang is #!/bin/tcsh
zsh  my_script.sh     # If the shebang is #!/bin/zsh
or better yet, just give the full or relative path of the script
Code:
./my_script.sh
then the shell used, is the same as the shebang.

No comments:

Post a Comment