[Tutor] problems with the shebang line and linux

David Rock david at graniteweb.com
Thu Feb 16 17:47:34 CET 2006


* Adam <adam.jtm30 at gmail.com> [2006-02-16 14:23]:
> On 16/02/06, Brian van den Broek <broek at cc.umanitoba.ca> wrote:
> 
> It seems to me that that ^M is your problem although I'm not quite sure
> where it came from there seems to be an extra character on the end of the
> copied one. Here's a little test I did:
> <code>
> #! /bin/py
> print "What the hell!!"
> </code>
> adam at darkstar:~$ ./test.py
> -bash: ./test.py: /bin/py: bad interpreter: No such file or directory
> and there doesn't seem to be any weird thing on the end even though that
> file doesn't exist.

I would verify that /bin/py is the actual location of your python
interperter. That's a really weird location.

> > I even retyped the testerlybar.py file, but I end up with the same
> > results as when the small script was copied and pasted.
> >
> > Likewise, I got the same results after saving the two files to my Home
> > directory on the hail mary thought that perhaps the fact I'd save the
> > originals on a FAT32 mounted drive might be making things goofy.
> >
> > I'm stumped. Any steps I can take to work out what's going on?

I have verified that ^M at the end _will_ break it.   I also verified
that having a space doesn't matter, either. Both work:
   #!/usr/bin/python
   #! /usr/bin/python

When you retyped it, what editor did you use?  

When you cat the file:
   cat testerlybar.py
What does the output look like?

If you have xxd installed (you probably do):
   xxd testerlybar.py
What does the output look like?  This will help us see EXACTLY what's in
the file. It will look something like this:
	drock at mojojojo ~ $ xxd foo.py 
	0000000: 2321 202f 7573 722f 6269 6e2f 7079 7468  #! /usr/bin/pyth
	0000010: 6f6e 0a70 7269 6e74 2022 4865 6c6c 6f22  on.print "Hello"
	0000020: 0a                                       .

Bottom line, the error means bash can not find the application you told
it to use, so something is wrong with the path you have in the file.

-- 
David Rock
david at graniteweb.com


More information about the Tutor mailing list