How to fix a /bin/sh^M : bad interpreter error
This is because of the line endings in your file are DOS line endings. The clue is the ^M. What you need to do is just re-save the file using Unix line endings.
To fix this, open your script with vi or vim and enter in vi command mode (key ESC), then type this:
:set fileformat=unix
Finally save it
:x! or :wq!
fonte: http://tombevers.me/2012/05/17/how-to-fix-a-binshm-bad-interpreter-error/