[Tutor] python scripting using "./"
Peter Otten
__peter__ at web.de
Tue May 24 15:38:31 CEST 2011
Hank Wilkinson wrote:
> I am trying to do script in python using "./"
> Here is a session showing "bad interpreter: No such file or directory"
> Is this a python question/problem?
It's a bash problem. The shell cannot cope with Windows line endings: ^M in
the error message stands for chr(13) or Carriage Return.
> -bash: ./hello.py: /usr/local/bin/python3.1^M: bad interpreter: No such
> file or directory John-Wilkinsons-iMac:p31summerfield wilkinson$ echo
There is a utility program called dos2unix to convert line endings, but I
don't know if it's available on the Mac.
$ cat -v tmp.py
#!/usr/bin/python^M
print "hello"^M
$ ./tmp.py
bash: ./tmp.py: /usr/bin/python^M: bad interpreter: No such file or
directory
$ dos2unix tmp.py
$ ./tmp.py
hello
$
More information about the Tutor
mailing list