Variations on a theme by "pound bang"

jam jam at newimage.com
Sun Jun 13 14:14:14 EDT 1999


On Sun, Jun 13, 1999 at 05:17:33PM +0000, Sean Mc Grath wrote:
> 
> Can anyone shed some light on the benefits of:-
> 
> # !/usr/bin/env python
> 
> as opposed to
> 
> # !/usr/bin/python
> 
> Sean
> 

yes. 

the first one is more generic, and independent of the actual location of the
command in question (in this case, the python interpreter). there's a man
page for 'env'-- it basically reads the PATH variable, and looks for it's
argument on it. a danger is that it might leave your scripts open to attack
(if someone manages to place a trojan program somewhere in the path *before*
the actual 'python' interpreter, say in $HOME/bin).

the 2nd one is specific to finding the python interpreter in '/usr/bin',
which might be fine for you, but I might install mine in /usr/local/bin
instead, for example. it's a bit more secure in that someone will have to
compromise /usr/bin, which is (theoretically) more difficult.

hope that helps.

regards,
J
-- 
|| visit gfd <http://quark.newimage.com/> 
|| psa member #293 <http://www.python.org/> 
|| New Image Systems & Services, Inc. <http://www.newimage.com/>




More information about the Python-list mailing list