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.
The script works but there is always a Command Not Found statement printed on screen for each empty line. Each blank line is resulting in a command not found.
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
Why would this occur?
Make sure your first line is:
Enter your path to bash if it is not
/bin/bashTry running:
That wil convert line endings, etc from Windows to unix format. i.e. it strips \r (CR) from line endings to change them from
\r\n (CR+LF)to\n (LF).More details about the
dos2unixcommand (man page)Another way to tell if your file is in dos/Win format:
The output will look something like this:
This will output the entire file text with
<CR>displayed for each\rcharacter in the file.