Re: #! syntax
On Wed, Feb 28, 2001 at 06:17:35PM +0000, David Wright wrote:
| Quoting D-Man (dsh8290@rit.edu):
| > On Mon, Feb 26, 2001 at 05:50:54PM +0100, Carel Fellinger wrote:
|
| > | You could consider:
| > |
| > | #!/usr/bin/env perl
| > |
| > | as more installs will have env in the same place.
| > |
| >
| > This is the correct way to begin python scripts (I can't say how the
| > perl community feels) :
| >
| >
| > #!/usr/bin/env python
| >
| > # python code here
|
| Well it's difficult to see much difference between these two
| suggestions.
It's the same, except that I don't know if the perl community takes an
opinion regarding the "correctness" of
#!/usr/bin/perl
vs.
#!/usr/bin/env perl
The python community prefers the latter version (s/perl/python of
course).
|
| > The idea is that env knows where stuff on the current machine is, so
| > simply ask it for the interperter you want (python, perl, bash, etc).
|
| AFAIK env knows nothing about "where stuff is". It just modifies
| the environment (nothing to do here as it happens) and runs perl
| or python (which are found through $PATH).
|
| > On a tangent, is there a way to manually configure env as to program
| > locations? In particular, how can I have env on my cygwin
| > installation know where python is (Win32 python build)? For now I
| > have my python script in foo.py with a wrapper foo that does :
| >
| > #!/bin/bash
| >
| > python foo.py $*
|
| I'm not sure what your difficulty is. Your $PATH presumably contains
| python so the env trick should work. The env trick is only necessary
| because #! requires the full path: although the path to perl may vary
| on different systems, the path to env is usually the same, /usr/bin/env.
| So you can use one script on the different systems and $PATH (different
| on different systems) will actually find perl, python or whatever.
|
Hmm, it's working now. I must not have had python in the path before.
I have a shell script in the path under my home directory that points
to the full path of the python executable.
| If you want to run a specific version of python, then just write its
| path in your script:
|
| #!/usr/bin/env /weird/path/python32
That defeats the purpose of using env as the first command ;-)
Thanks,
-D
Reply to: