Wednesday, June 25, 2014

Solving Error: “syntax error near unexpected token”

Detail Error:
: command not found
: command not found
'/build.sh: line 3: syntax error near unexpected token `{
'/build.sh: line 3: `function stop_channels(){

was thrown when I run
./build.sh

The issue was I opened the .sh (shell script) in Windows OS and Windows changed the end of the line to CRLF

I found this out by running

cat --show-nonprinting filename.extension
E.g.

cat --show-nonprinting test.sh

Or open the file in Notepad++ and click on the button circled in the figure below.

windows vs linux.PNG

Then, I converted it using

dos2unix filename.extension
[Install dos2unix if required]
E.g.

dos2unix myfile.txt
dos2unix myshell.sh



No comments:

Post a Comment