Monday, February 1, 2016

Solving ^M command not found error when submitting jobs to Platform LSF Scheduler

When submitting a job to the Platform LSF, I got error like below on the error files
/home/user1/.lsbatch/1454303769.93618.shell: line 2: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 5: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 8: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 12: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 15: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 18: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 21: ^M: command not found
/home/user1/.lsbatch/1454303769.93618.shell: line 25: syntax error near unexpected token `do^M'
/home/user1/.lsbatch/1454303769.93618.shell: line 25: `do^M'

The errors occurred when there is a lots of shell spaces left in the script and this shell file is usually caused by writing and saving the file in Windows which peppered it its own format. The only solution is to use the dos2unix utilities found in linux to solve the issue

# dostounix yourscript.sh

References:
  1. [How To] Solve “command not found: ^M” Shell Error

No comments: