Re: executable python scripts

Rickard Westman (ricwe@ida.liu.se)
Fri, 24 Mar 1995 18:08:09 GMT

sst@bouw.tno.nl (Tako Schotanus) writes:

>In article <9503211300.AA06750=guido@voorn.cwi.nl>, Guido.van.Rossum@cwi.nl says:
>>> I then made the following file (called fred),
>>>
>>> #!/data/maths/graham/APP/PYTHON/bin/python
>>> print "a"
>>>
>>> Now when I run fred by doing say "./fred", I get the message
>>> "./fred: Permission denied.".
>>
>>Some OS'es have a limit of 32 bytes on the pathname used here. Try a
>>shorter path... (It may be a symbolic link I think.)

This can be a problem if you don't have permission to put symlinks
(or the Python interpretor) in a directory with a short path.
Perhaps you are a student who only has access to his/her own home
directory. Then, a useful trick is to use

#!/bin/env python

as the first line of the script. This will look for the python
interpreter in your standard search path. (You have to have
/bin/env, of course, but I think it is fairly standard.)

>The problem could also be the shell you're using: I have the same
>problem sometimes with newly created shell-scripts, my shell just
>doesn't seem to understand what it should do. Everything works fine
>though after I started a new shell (normally I open a new xterm and
>close the old one, in the new one everything works just fine. Why?
>Beats me :( )

Perhaps you are relying on the search path to find your newly
created script? In that case you need to do "rehash" (for
csh-derived shells, at least), since the shell caches the names of
all executables in your search path, and won't update the cache
automatically when new executables are added.

--
Rickard Westman                   |   "Beware of the panacea peddlers:
Dept. of Computer Science         |    Just because you wind up naked 
Linkvping University              |    doesn't make you an emperor."  
Sweden                            |              - Michael A Padlipsky