Every time I run a script using bash scriptname.sh
from the command line in Debian, I get Command Not found
and then the result of the script. So the script works but there is always a Command Not Found
statement printed on screen.
I am running the script from the /var
folder.
Here is the script:
#!/bin/bash
echo Hello World
I run it by typing the following:
bash testscript.sh
UPDATE - the problem appears to the blank lines. Each blank line is resulting in a command not found. Why would this occur?
I also ran into a similar issue. The issue seems to be permissions. If you do an
ls -l
, you may be able to identify that your file may NOT have the execute bit turned on. This will NOT allow the script to execute. :)As @artooro added in comment:
You can use
bash -x scriptname.sh
to trace it.Had the same problem. Unfortunately
so I did this to convert.
and then
Try
chmod u+x testscript.sh
I know it from here: http://www.linuxquestions.org/questions/red-hat-31/running-shell-script-command-not-found-202062/