Hello I am lost sorry I dont know why my script wont run
my script is: echo "hi"
when i type: sudo ./my.sh
it shows: unable to excute my.sh: no such file or directory hangup
and when i type: ./my.sh
it shows: -bash: ./my.sh: bin/bash: bad interpreter: no such file or directory
it would be great if you can help me thank you very much
32 Answers
Three things:
Why the sudo? At this point, you do not want to run your script as root.
All your scripts need to start with the interpreter on the first line It's the comment sign followed by an exclamation sign. (The "Shebang") For bash, your script would look like this:
#!/bin/bashecho "hi"You should make your scripts executable with
chmod 700 myscript.sh. Only then can you execute them like this./myscript.sh
On a related note, this is not specifically a Ubuntu question, but a generic scripting question.
3/usr/bin/bash $HOME/my.sh
Try this and see the difference, you probably are not in the right directory to execute a file. cd or pwd and ls to make sure what you are doing.