linux - bash script always prints "Command Not Found" -
every time run script using bash scriptname.sh
command line in debian, command not found
, result of script. script works there command not found
statement printed on screen.
i running script /var
folder.
here script:
#!/bin/bash echo hello world
i run typing following:
bash testscript.sh
update - problem appears blank lines. each blank line resulting in command not found. why occur?
make sure first line is:
#!/bin/bash
enter path bash if not /bin/bash
try running:
dos2unix script.sh
that wil convert line endings, etc windows unix format. i.e. strips \r (cr) line endings alter them \r\n (cr+lf)
\n (lf)
.
more details dos2unix
command (man page)
another way tell if file in dos/win format:
cat scriptname.sh | sed 's/\r/<cr>/'
the output this:
#!/bin/sh<cr> <cr> echo hello world<cr> <cr>
this output entire file text <cr>
displayed each \r
character in file.
p.s. sorry poor formatting, written iphone while driving work :p.
linux bash debian
No comments:
Post a Comment