If you need to use dos2unix, you probably have a file edited on Windows and I never used dos2unix, since modrn editors on Windows can edit Linux compatible files, but if you have Windows line ending at the end of the first line, the shebang line will be invalid and you will get exactly the error message you got. So try an IDE or editor that can show if your file has CRLF (Windows line ending) or LF (Linux line ending) and use only LF in shell scripts.