[24641] in Perl-Users-Digest
Perl-Users Digest, Issue: 6805 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 3 12:56:35 2004
Date: Tue, 3 Aug 2004 09:55:48 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 3 Aug 2004 Volume: 10 Number: 6805
Today's topics:
creating shell scripts using #!/usr/local/env perl <david@tvisnospam.co.uk>
Re: creating shell scripts using #!/usr/local/env perl <mritty@gmail.com>
Re: creating shell scripts using #!/usr/local/env perl <david@tvisnospam.co.uk>
Re: creating shell scripts using #!/usr/local/env perl <mritty@gmail.com>
Re: creating shell scripts using #!/usr/local/env perl <david@tvisnospam.co.uk>
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Re: creating shell scripts using #!/usr/local/env perl (Peter J. Acklam)
Re: creating shell scripts using #!/usr/local/env perl <Juha.Laiho@iki.fi>
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Re: creating shell scripts using #!/usr/local/env perl <gnari@simnet.is>
Re: creating shell scripts using #!/usr/local/env perl <bik.mido@tiscalinet.it>
Re: creating shell scripts using #!/usr/local/env perl (Peter J. Acklam)
Re: creating shell scripts using #!/usr/local/env perl <abigail@abigail.nl>
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Re: creating shell scripts using #!/usr/local/env perl <david@tvisnospam.co.uk>
Re: creating shell scripts using #!/usr/local/env perl <david@tvisnospam.co.uk>
Re: creating shell scripts using #!/usr/local/env perl <sholden@flexal.cs.usyd.edu.au>
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Re: creating shell scripts using #!/usr/local/env perl (Anno Siegel)
Re: creating shell scripts using #!/usr/local/env perl <bik.mido@tiscalinet.it>
Re: creating shell scripts using #!/usr/local/env perl <vek@station02.ohout.pharmapartners.nl>
Re: creating shell scripts using #!/usr/local/env perl <bik.mido@tiscalinet.it>
Re: creating shell scripts using #!/usr/local/env perl (Anno Siegel)
Re: creating shell scripts using #!/usr/local/env perl <tzz@lifelogs.com>
Re: creating shell scripts using #!/usr/local/env perl (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 02 Aug 2004 14:40:09 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: creating shell scripts using #!/usr/local/env perl
Message-Id: <5kgsg0dopqr8u9eie58rnnrlvrtr1k1f95@4ax.com>
Hi
I've recently discovered that you call write "perl" Shell scripts using
the following bang
#!/usr/local/env perl
This is really cute but,I've already discovered one limitation , you cannot call such a script via
the dot method (seems to ignore the bang)
But where can I learn more about #!/usr/local/env perl ???
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: Mon, 2 Aug 2004 09:47:36 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <20040802094709.T14831@barbara.cs.rpi.edu>
On Mon, 2 Aug 2004, zzapper wrote:
> Hi
> I've recently discovered that you call write "perl" Shell scripts using
> the following bang
>
> #!/usr/local/env perl
>
> This is really cute but,I've already discovered one limitation , you cannot call such a script via
> the dot method (seems to ignore the bang)
>
> But where can I learn more about #!/usr/local/env perl ???
man env
Paul Lalli
------------------------------
Date: Mon, 02 Aug 2004 15:02:28 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <o9isg056i3ajsiogfe26meloo96hu1otv0@4ax.com>
On Mon, 2 Aug 2004 09:47:36 -0400, wrote:
>On Mon, 2 Aug 2004, zzapper wrote:
>
>> Hi
>> I've recently discovered that you call write "perl" Shell scripts using
>> the following bang
>>
>> #!/usr/local/env perl
>>
>> This is really cute but,I've already discovered one limitation , you cannot call such a script via
>> the dot method (seems to ignore the bang)
>>
>> But where can I learn more about #!/usr/local/env perl ???
>
>man env
>
>
>Paul Lalli
did you actually read the man page for env? there's no mention of using env as I suggest?
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: Mon, 2 Aug 2004 10:13:31 -0400
From: Paul Lalli <mritty@gmail.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <20040802101027.Y14831@barbara.cs.rpi.edu>
On Mon, 2 Aug 2004, zzapper wrote:
> On Mon, 2 Aug 2004 09:47:36 -0400, wrote:
>
> >On Mon, 2 Aug 2004, zzapper wrote:
> >
> >> Hi
> >> I've recently discovered that you call write "perl" Shell scripts using
> >> the following bang
> >>
> >> #!/usr/local/env perl
> >>
> >> This is really cute but,I've already discovered one limitation , you cannot call such a script via
> >> the dot method (seems to ignore the bang)
> >>
> >> But where can I learn more about #!/usr/local/env perl ???
> >
> >man env
> >
> >
> >Paul Lalli
> did you actually read the man page for env? there's no mention of using env as I suggest?
Did you read it? Did you understand it?
The env utility obtains the current environment, modifies it
according to its arguments, then invokes the utility named
by the utility operand with the modified environment.
All your 'cute' shebang is doing is calling 'perl' using the default
current environment, that is, without modifying the environment at all.
This is useful for transporting perl scripts from one machine to another,
where it's possible the 'correct' perl to use is in, say, /usr/local/bin
rather than /usr/bin. This way, you will always call the instance of
perl that would be called if you simply typed 'perl' at the shell prompt,
rather than hardcoding a location.
Paul Lalli
------------------------------
Date: Mon, 02 Aug 2004 15:25:34 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <6gjsg0lr6a11ceof61sr1ctjnsdb0qhr48@4ax.com>
On Mon, 2 Aug 2004 10:13:31 -0400, wrote:
>On Mon, 2 Aug 2004, zzapper wrote:
>
>> On Mon, 2 Aug 2004 09:47:36 -0400, wrote:
>>
>> >On Mon, 2 Aug 2004, zzapper wrote:
>Did you read it? Did you understand it?
>
> The env utility obtains the current environment, modifies it
> according to its arguments, then invokes the utility named
> by the utility operand with the modified environment.
>
>All your 'cute' shebang is doing is calling 'perl' using the default
>current environment, that is, without modifying the environment at all.
>This is useful for transporting perl scripts from one machine to another,
>where it's possible the 'correct' perl to use is in, say, /usr/local/bin
>rather than /usr/bin. This way, you will always call the instance of
>perl that would be called if you simply typed 'perl' at the shell prompt,
>rather than hardcoding a location.
>
>Paul Lalli
Paul,
On close my extremely brief env man page says "The full documentation for env is maintained as a
Texinfo manual" I'd missed that, so apologies. But in any case I'm interested in learning a bit more
about Perl/Shell interations, where can I find that?
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: 02 Aug 2004 07:44:18 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <86smb5y4zh.fsf@blue.stonehenge.com>
>>>>> "zzapper" == zzapper <david@tvisnospam.co.uk> writes:
zzapper> Hi
zzapper> I've recently discovered that you call write "perl" Shell scripts using
zzapper> the following bang
zzapper> #!/usr/local/env perl
That won't work on my machine. And "env" is in different places
on different machines, and even not present on some machines.
Hence, it only works for some odd value of "works".
Best to stay away from it.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 02 Aug 2004 19:04:31 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <fz75sc80.fsf@online.no>
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "zzapper" == zzapper <david@tvisnospam.co.uk> writes:
>
> zzapper> #!/usr/local/env perl
>
> That won't work on my machine. And "env" is in different places
> on different machines, and even not present on some machines.
>
> Hence, it only works for some odd value of "works".
>
> Best to stay away from it.
If "env" is present on all the machines used by "zzapper", I see
no problem with it. It all depends on the environment. Our
systems run numerous different versions of Solaris, where the
location "perl" varies, but the location of "env" is fixed, so the
natural choice for me is to use "env".
Of course, it might be better to use "#!/bin/sh" which execs
"perl"...
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: Mon, 02 Aug 2004 18:37:03 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <cem1gc$q9s$1@ichaos.ichaos-int>
zzapper <david@tvisnospam.co.uk> said:
>On Mon, 2 Aug 2004 10:13:31 -0400, Paul Lalli wrote:
>>All your 'cute' shebang is doing is calling 'perl' using the default
>>current environment, that is, without modifying the environment at all.
...
>But in any case I'm interested in learning a bit more about Perl/Shell
>interations, where can I find that?
But the technique you described (using 'env' as the command on the shebang
line, and giving the actual command to execute as a parameter to 'env')
doesn't have any relation to perl. It's a pure shell issue; you can run
pretty much any command using the same technique. So, the place for these
is one of comp.unix.shell, comp.unix.questions, or comp.unix.misc.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: 02 Aug 2004 12:26:05 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <861xipxrxu.fsf@blue.stonehenge.com>
>>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
Peter> If "env" is present on all the machines used by "zzapper", I see
Peter> no problem with it. It all depends on the environment. Our
Peter> systems run numerous different versions of Solaris, where the
Peter> location "perl" varies, but the location of "env" is fixed, so the
Peter> natural choice for me is to use "env".
You apparently missed the part where I said "env is in different places
even on the machines that have it". So, you already have to fix
the path! Might as well fix it to be right.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 2 Aug 2004 20:02:18 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <cem6gf$o3n$1@news.simnet.is>
"zzapper" <david@tvisnospam.co.uk> wrote in message
news:6gjsg0lr6a11ceof61sr1ctjnsdb0qhr48@4ax.com...
> On Mon, 2 Aug 2004 10:13:31 -0400, wrote:> Paul,
> On close my extremely brief env man page says "The full documentation
for env is maintained as a
> Texinfo manual" I'd missed that, so apologies. But in any case I'm
interested in learning a bit more
> about Perl/Shell interations, where can I find that?
that would be perldoc perlrun
gnari
------------------------------
Date: Mon, 02 Aug 2004 23:08:52 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <aqatg01pt736khh25gkhj5q9dhgigc90bg@4ax.com>
On Mon, 02 Aug 2004 14:40:09 GMT, zzapper <david@tvisnospam.co.uk>
wrote:
>I've recently discovered that you call write "perl" Shell scripts using
>the following bang
>
>#!/usr/local/env perl
I strongly suppose you do know that this is not strictly perl-related.
However there's already been some discussion here about pros and cons
of that kind of shebang.
>This is really cute but,I've already discovered one limitation , you cannot call such a script via
>the dot method (seems to ignore the bang)
Please pardon my ignorance, but... what is the "dot method"?
Honestly, I'd be curious to know what it is, since the way you talk
about it suggests that is something that should be popular enough to
be widely known...
>But where can I learn more about #!/usr/local/env perl ???
Re "#!/usr/local/env perl" I'd say on google looking for the
discussions briefly hinted to above. Re "#!/usr/local/env", which may
be relevant enough re perl, I'd say "man env"...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 02 Aug 2004 23:47:04 +0200
From: pjacklam@online.no (Peter J. Acklam)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <8ycxrz53.fsf@online.no>
merlyn@stonehenge.com (Randal L. Schwartz) wrote:
> >>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
>
> Peter> If "env" is present on all the machines used by
> Peter> "zzapper", I see no problem with it. It all depends on
> Peter> the environment. Our systems run numerous different
> Peter> versions of Solaris, where the location "perl" varies,
> Peter> but the location of "env" is fixed, so the natural choice
> Peter> for me is to use "env".
>
> You apparently missed the part where I said "env is in different
> places even on the machines that have it". So, you already have
> to fix the path! Might as well fix it to be right.
What I meant was: If "env" is present and has the same location
on all the machines used by "zzapper", I see no problem with it.
Peter
--
#!/local/bin/perl5 -wp -*- mode: cperl; coding: iso-8859-1; -*-
# matlab comment stripper (strips comments from Matlab m-files)
s/^((?:(?:[])}\w.]'+|[^'%])+|'[^'\n]*(?:''[^'\n]*)*')*).*/$1/x;
------------------------------
Date: 02 Aug 2004 22:57:03 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <slrncgthlv.i4t.abigail@alexandra.abigail.nl>
Paul Lalli (mritty@gmail.com) wrote on MMMCMLXXXIX September MCMXCIII in
<URL:news:20040802101027.Y14831@barbara.cs.rpi.edu>:
^^
^^ All your 'cute' shebang is doing is calling 'perl' using the default
^^ current environment, that is, without modifying the environment at all.
^^ This is useful for transporting perl scripts from one machine to another,
^^ where it's possible the 'correct' perl to use is in, say, /usr/local/bin
^^ rather than /usr/bin. This way, you will always call the instance of
^^ perl that would be called if you simply typed 'perl' at the shell prompt,
^^ rather than hardcoding a location.
\begin{sarcasm}
Yes, and the gain of not having to hardcode the path to perl comes
with the price of having to hardcode the path to env.
\end{sarcasm}
Abigail
--
#!/opt/perl/bin/perl -w
$\ = $"; $SIG {TERM} = sub {print and exit};
kill 15 => fork for qw /Just another Perl Hacker/;
------------------------------
Date: 02 Aug 2004 16:04:11 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <86hdrlw39w.fsf@blue.stonehenge.com>
>>>>> "Peter" == Peter J Acklam <pjacklam@online.no> writes:
Peter> What I meant was: If "env" is present and has the same location
Peter> on all the machines used by "zzapper", I see no problem with it.
You can replace "env" with "perl" there, and it still applies, and
my statement applies as well. I don't know why you keep wanting to
introduce an additional complexity and inefficiency.
1) You can't guarantee that env is there
2) even if it is, it might be in different places
3) even if it works, it causes an extra fork, and messes up the other #! switches
Therefore, WHY USE ENV???
Get my point now?
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Tue, 03 Aug 2004 01:48:54 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <0tntg0tfkehicncskvgs3furu5ors8smnc@4ax.com>
On 02 Aug 2004 22:57:03 GMT, wrote:
>Paul Lalli (mritty@gmail.com) wrote on MMMCMLXXXIX September MCMXCIII in
><URL:news:20040802101027.Y14831@barbara.cs.rpi.edu>:
>^^
>^^ All your 'cute' shebang is doing is calling 'perl' using the default
>^^ current environment, that is, without modifying the environment at all.
>^^ This is useful for transporting perl scripts from one machine to another,
>^^ where it's possible the 'correct' perl to use is in, say, /usr/local/bin
>^^ rather than /usr/bin. This way, you will always call the instance of
>^^ perl that would be called if you simply typed 'perl' at the shell prompt,
>^^ rather than hardcoding a location.
>
>
>\begin{sarcasm}
>
>Yes, and the gain of not having to hardcode the path to perl comes
>with the price of having to hardcode the path to env.
>
>\end{sarcasm}
>
>
>
>Abigail
\begin{Isqueezeinfooutofexperts}
Actually as env is always available you can do
#!env perl
But to be sure I'm no longer sure whether there are any benefits to the method, beyond a little
extra portability
As on my system (CygWin) I can always do
#!perl
\end{Isqueezeinfooutofexperts}
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: Tue, 03 Aug 2004 02:06:45 GMT
From: zzapper <david@tvisnospam.co.uk>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <ngotg0dg37gaqk3mf48mgojgjrbkcj6kcb@4ax.com>
On Mon, 2 Aug 2004 20:02:18 -0000, wrote:
>"zzapper" <david@tvisnospam.co.uk> wrote in message
>news:6gjsg0lr6a11ceof61sr1ctjnsdb0qhr48@4ax.com...
>> On Mon, 2 Aug 2004 10:13:31 -0400, wrote:> Paul,
>> On close my extremely brief env man page says "The full documentation
>for env is maintained as a
>> Texinfo manual" I'd missed that, so apologies. But in any case I'm
>interested in learning a bit more
>> about Perl/Shell interations, where can I find that?
>
>that would be perldoc perlrun
>
>gnari
>
>
Gnari
Thanx and curiously when I run it what appears
print << __HEREIAMBABY;
A similar trick involves the env program, if you have it.
#!/usr/bin/env perl
The examples above use a relative path to the perl interpreter, getting whatever version is first in
the user's path. If you want a specific version of Perl, say, perl5.005_57, you should place that
directly in the #! line's path.
__HEREIAMBABY
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: 3 Aug 2004 01:34:34 GMT
From: Sam Holden <sholden@flexal.cs.usyd.edu.au>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <slrncgtqta.l8s.sholden@flexal.cs.usyd.edu.au>
On Tue, 03 Aug 2004 01:48:54 GMT, zzapper <david@tvisnospam.co.uk> wrote:
>
> Actually as env is always available you can do
>
> #!env perl
>
> But to be sure I'm no longer sure whether there are any benefits to the method, beyond a little
> extra portability
If you define portability as "works on at least one system". But not on those
uncommon systems like linux and solaris - no one uses them anyway...
--
Sam Holden
------------------------------
Date: 02 Aug 2004 18:42:40 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <86wu0huhdb.fsf@blue.stonehenge.com>
>>>>> "zzapper" == zzapper <david@tvisnospam.co.uk> writes:
zzapper> Actually as env is always available you can do
No it is not. It's not part of POSIX.
zzapper> #!env perl
And this doesn't work unless env is in the current directory.
{sigh}
Please stop posting things that contradict the experts.
{sigh}
You're wasting our time.
zzapper> As on my system (CygWin) I can always do
zzapper> #!perl
And that's not a Unix system. Stop bringing in irrelevant data.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 02 Aug 2004 18:44:32 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <86pt69uha7.fsf@blue.stonehenge.com>
>>>>> "zzapper" == zzapper <david@tvisnospam.co.uk> writes:
zzapper> Thanx and curiously when I run it what appears
zzapper> print << __HEREIAMBABY;
zzapper> A similar trick involves the env program, if you have it.
zzapper> #!/usr/bin/env perl
And that FAQ needs an update. The person who wrote it was unaware
that "env" is neither universally available, nor located in identical
places.
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 3 Aug 2004 08:13:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <cenhf7$kfl$1@mamenchi.zrz.TU-Berlin.DE>
Michele Dondi <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On Mon, 02 Aug 2004 14:40:09 GMT, zzapper <david@tvisnospam.co.uk>
> wrote:
[...]
> >This is really cute but,I've already discovered one limitation , you
> cannot call such a script via
> >the dot method (seems to ignore the bang)
>
> Please pardon my ignorance, but... what is the "dot method"?
Unix shells have a built-in command to read a file and interpret the
content as commands in the currently running shell. With Bourne-like
shells, this command is ".", so the process may be called the "dot
method". (With csh-like shells, the command is "source".)
The interpreting shell is fixed with these commands, it is the
shell that is already running. There is no room for switching
to another, and so there is no way these scripts could honor the
shebang line.
> Honestly, I'd be curious to know what it is, since the way you talk
> about it suggests that is something that should be popular enough to
> be widely known...
It is popular and widely known among shell programmers. It has
nothing to do with Perl.
Anno
------------------------------
Date: Tue, 03 Aug 2004 10:28:24 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <45ctg0pocvvro8j421t197vrgskdvq25p4@4ax.com>
On 02 Aug 2004 07:44:18 -0700, merlyn@stonehenge.com (Randal L.
Schwartz) wrote:
>zzapper> #!/usr/local/env perl
>
>That won't work on my machine. And "env" is in different places
>on different machines, and even not present on some machines.
>
>Hence, it only works for some odd value of "works".
Thus it suffers from the same problem it aims at solving... funny!
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 03 Aug 2004 11:19:30 GMT
From: Villy Kruse <vek@station02.ohout.pharmapartners.nl>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <slrncgut62.uc.vek@station02.ohout.pharmapartners.nl>
On 02 Aug 2004 18:42:40 -0700,
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
>>>>>> "zzapper" == zzapper <david@tvisnospam.co.uk> writes:
>
>zzapper> Actually as env is always available you can do
>
> No it is not. It's not part of POSIX.
>
I'm afraid it is:
|
| The Open Group Base Specifications Issue 6
| IEEE Std 1003.1, 2004 Edition
| Copyright © 2001-2004 The IEEE and The Open Group, All Rights
| reserved.
| _________________________________________________________________
|
| NAME
|
| env - set the environment for command invocation
|
| SYNOPSIS
|
| env [-i][name=value]... [utility [argument...]]
| [ ... ]
It still doesn't say if env belongs in /bin/env, /usr/bin/env,
/usr/local/bin/env. The location /usr/local/env as mentioned in the
subject isn't very likely to be found on many systems, though.
Villy
------------------------------
Date: Tue, 03 Aug 2004 14:56:45 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <1b2vg0p0bvlbitl0cadb50hqqqdovrmvc3@4ax.com>
On 3 Aug 2004 08:13:27 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
Siegel) wrote:
>> >This is really cute but,I've already discovered one limitation , you
>> >cannot call such a script via
^^^^
^^^^
>> >the dot method (seems to ignore the bang)
>>
>> Please pardon my ignorance, but... what is the "dot method"?
>
>Unix shells have a built-in command to read a file and interpret the
>content as commands in the currently running shell. With Bourne-like
Oh, but then I *do* know what it is. Only I was misleaded by the
expression used above by the OP, since as I have always understood it,
the "dot method" is just... er, well, to repeat exactly you words, "to
read a file and interpret the content as commands in the currently
running shell", so that it shouldn't come as a surprise that "shebang
line isn't honoured", but is *should* come as a surprise that it
doesn' fail at all, instead.
>The interpreting shell is fixed with these commands, it is the
>shell that is already running. There is no room for switching
>to another, and so there is no way these scripts could honor the
>shebang line.
But then again, if I have ever understood the whole thing correctly
there's no way for the currently running shell to understand that it
is a perl script at all. And this is why I couldn't understand what it
was abouty, since I wouldn't reagard the "dot method" as a means to
"call a (perl - or whatever!) script".
>> Honestly, I'd be curious to know what it is, since the way you talk
>> about it suggests that is something that should be popular enough to
>> be widely known...
>
>It is popular and widely known among shell programmers. It has
>nothing to do with Perl.
FWIW my distro init scripts are (reasonably enough!) full of such
constructs...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: 3 Aug 2004 13:15:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <ceo35e$ro6$4@mamenchi.zrz.TU-Berlin.DE>
Michele Dondi <bik.mido@tiscalinet.it> wrote in comp.lang.perl.misc:
> On 3 Aug 2004 08:13:27 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
[...]
> >> Please pardon my ignorance, but... what is the "dot method"?
[...]
> >The interpreting shell is fixed with these commands, it is the
> >shell that is already running. There is no room for switching
> >to another, and so there is no way these scripts could honor the
> >shebang line.
>
> But then again, if I have ever understood the whole thing correctly
> there's no way for the currently running shell to understand that it
> is a perl script at all. And this is why I couldn't understand what it
> was abouty, since I wouldn't reagard the "dot method" as a means to
> "call a (perl - or whatever!) script".
Quite so. The content of a "dot file" must be interpretable by the
current shell. No other language will do.
Anno
------------------------------
Date: Tue, 03 Aug 2004 11:12:11 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <4n4qnk1cj8.fsf@lifelogs.com>
On Mon, 02 Aug 2004, david@tvisnospam.co.uk wrote:
> I've recently discovered that you call write "perl" Shell scripts using
> the following bang
>
> #!/usr/local/env perl
>
> This is really cute but,I've already discovered one limitation , you
> cannot call such a script via the dot method (seems to ignore the
> bang)
The env program itself may pick up the wrong Perl. Consider:
PATH /usr/bin
env perl => /usr/bin/perl
PATH /usr/local/bin
env perl => /usr/local/bin/perl
So an incorrect path may cause the wrong or no version of Perl to be
picked up, depending on the USER's settings.
As others pointed out, you may as well specify the path yourself.
This is still not possible sometimes across various machines, so you
can:
a) set up a templating system, e.g. autoconf, which will rewrite the
script with the correct shebang line when it's installed;
b) write a shell wrapper that chooses the right version of Perl based
on the output of uname, for instance.
Ted
------------------------------
Date: 03 Aug 2004 08:26:19 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: creating shell scripts using #!/usr/local/env perl
Message-Id: <861xioutt0.fsf@blue.stonehenge.com>
>>>>> "Villy" == Villy Kruse <vek@station02.ohout.pharmapartners.nl> writes:
>> No it is not. It's not part of POSIX.
>>
Villy> I'm afraid it is:
Argh! What did they do *that* for? That's crazy!
The only reason "env" exists is because the brain-dead csh can't add
arbitrary env vars per command. The One True Shell (/bin/sh) knew how
to do it, but the boys at berkeley all liked the csh better I guess,
so they worked around the per-command env settings by adding yet
another tool instead of fixing csh.
In the bourne shell, you simply say this:
$ ONEOFF=thisval TWOTHING=thatval some_command with these args
No need for a freaking env command.
Man, when will people stop tinkering with things.
print "Just another Perl hacker,"; # and into rant mode so early in the morning
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6805
***************************************