to solve the problem:
Shell script execution - command not found, syntax error near unexpected token
When we edit shell script in Windows machine, and ftp it to Linux for execution, sometimes we hit the following error:
“command not foundh” line xxx
“command not foundne” line xxx: syntax error near unexpected token `
This is due to the newline characters used on both systems. We need to replace all occurances of "\r\n" with "\n".
In vi, do the following:
// Change from (DOS) to just (Unix):
:set fileformat=unix
:w
// change back to Carriage Return + Line Feed for DOS
:set fileformat=dos
:w
// writing for apple computers:
:set fileformat=mac
:w
// remove multiple (repeated) Carriage Returns using search and replace
:%s/[^M]$//
:w
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment