-1

I have taken this example in this post shell start / stop for python script however I am getting a syntax error:

> : command not found 2:
: command not found 6:
'op.sh: line 8: syntax error near unexpected token `{
'op.sh: line 8: `running() {

I am running CentOS 6.

Community
  • 1
  • 1
Johnathon64
  • 1,280
  • 1
  • 20
  • 45

1 Answers1

1

Your getting this set of errors because you have an extra "Windows" character at the end of the line.

Usual Linux files normally end their lines with one char \n - meaning something like "next line" - whereas "Windows" files' lines end with the two chars \r\n - "next line - carriage return"... Don't ask me what the carriage is on a laptop those days.

This is a common issue, all of programmers will face in their life. See how Difference between \n and \r? ranks for example!

There is a Linux utility to do the conversion between OS for you:

dos2unix myscript.windows myscript.linux
Community
  • 1
  • 1
J. Chomel
  • 8,193
  • 15
  • 41
  • 69
  • This is a good answer. Please add more info so SO engine will not mark it as low quality. – Jayan Apr 22 '16 at 03:55