Interpreter problem

Steve Holden steve at holdenweb.com
Fri Apr 8 12:29:34 EDT 2005


rbt wrote:
> Steve Holden wrote:
> 
>> rbt wrote:
>>
>>> Steve Holden wrote:
>>>
>>>> Greg Lindstrom wrote:
>>>>
>>>>> I am using python 2.3.5 on a Linux system and have an odd problem 
>>>>> dealing with the 'sha-bang' line.  I have a file, driver.py which 
>>>>> starts with
>>>>>
>>>>> #!/usr/bin/python
>>>>>
>>>>> and works fine (that is, when I type in ./driver.py at the command 
>>>>> prompt the file runs as expected).  I have another file, 
>>>>> myotherfile.py which starts with the exact same line 
>>>>> (#!/usr/bin/python) but I get
>>>>>
>>>>> : bad interpreter: No such file or directory
>>>>>
>>>> There's almost certainly a carriage return as well as a newline in 
>>>> the shebang line.
>>>>
>>>> [...]
>>>>
>>>> regards
>>>>  Steve
>>>
>>>
>>>
>>>
>>> Not so. I get the same result with python 2.3 and 2.4 on Debian Linux 
>>> Testing. Nothing odd at all in the shebang.
>>
>>
>>
>> What, you are telling me you've checked the file with a command like
>>
>>   head driver.py | od -bc
>>
>> and verified the absence of any extraneous characters?
>>
>> regards
>>  Steve
> 
> 
> You're right:
> 
> rbt at athop1:~$ cd /usr/local/bin
> rbt at athop1:/usr/local/bin$ head web* | od -bc
> 0000000 043 041 057 165 163 162 057 142 151 156 057 160 171 164 150 157
>           #   !   /   u   s   r   /   b   i   n   /   p   y   t   h   o
> 0000020 156 015 012 144 145 146 040 167 145 142 137 142 141 143 153 165
>           n  \r  \n
> 
Nice to know my psychic powers are still functioning correctly :-)

> How can this be fixed? vim doesn't see it.

Do you have a "dos2unix" utility? Otherwise use "tr" to delete \013 
characters, IIRC - it's a while since I used anything but dos2unix to do 
this.

Of course you could just read and write the file in Python in text mode, 
that might get rid of the returns.

There's probably a vim mode you can set to display the extraneous 
characters - it normally screams "^M" at me for files with carriage 
returns in them. You may find it telling you the file is being edits in 
"DOS mode" when you open it up, and again there's probably vim magic you 
can do to force it to write in "unix mode" too - I'll leave that to the 
vimsters.

regards
  Steve
-- 
Steve Holden        +1 703 861 4237  +1 800 494 3119
Holden Web LLC             http://www.holdenweb.com/
Python Web Programming  http://pydish.holdenweb.com/




More information about the Python-list mailing list