Earlier today I was trying to run a Python script that I downloaded from the internet. Bash (or the kernel, to be exact) refused to run the script, insisting that python didn’t exist:
$ mem.py -bash: /home/natan/bin/mem.py: /usr/local/bin/python2.5^M: bad interpreter: No such file or directory
The script agreed to run indirectly with python ~/bin/mem.py
I googled and discovered that the file was encoded in DOS format with improper line endings.
To fix the problem, I copied the contents of the file and pasted them into a new file. Voilà. The shebang became magical again.
Then again, you can also fix the problem permanently. (Don’t.)
ln -s sh "sh$(printf "\r")"
photo credit: Sven & Lirion