I have seen this issue when creating scripts in Windows env and then porting over to run on a Unix environment.
Try running dos2unix
on the script:
http://dos2unix.sourceforge.net/
Or just rewrite the script in your Unix env using vi
and test.
Unix uses different line endings so can't read the file you created on Windows. Hence it is seeing ^M as an illegal character.
If you want to write a file on Windows and then port over, make sure your editor is set to create files in UNIX format.
In notepad++ in the bottom right of the screen, it tells you the document format. By default, it will say DosWindows
. To change it go to
- settings->preferences
- new document / default directory tab
- select the format as unix and close
- create a new document
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…