Originally Posted by dive
If you copied and pasted from a website you might some windows control codes in there so try writing it out from scratch and make sure file format is unix.
This is actually a very promising explanation. Even if it wasn't copied from a webpage, if you typed it up on a Windows box and then uploaded it, the problem likely is the file format. Yes, text is text...but there are
difference bewteen *nix and Windows, especially in newlines.
Be sure you have opened the script up with a text editor on the server to check for hidden characters. Even if you don't write out the whole thing from scratch, at least rewrite the first line--but do it in-place, on the server, rather than on a Windows box and then uploading.
And just so that there is no confusion, put the sha-bang line as the first line:
No spaces in that. That way, there is no question what the interpreter is (although it looks like bash reporting the errors to me...)