Re: #! syntax
On Mon, Feb 26, 2001 at 04:23:52PM -0300, Christoph Simon wrote:
>
> This one should work (didn't try it):
>
> #!/bin/sh
>
> PERL=`which perl`
> tail +7 $0 | $PERL
> exit 0
>
> # start perl code
> ...
>
> ..assuming that perl code starts on line 7.
it wouldn't be Perl if there wasn't yet another way to do it:
#!/bin/sh
exec perl -x $0 "$@"
#!perl
# your perl code here ...
See the manpage 'perlrun' for why this works. Additional options to perl
can be put where the "-x" is.
cheers,
Erdmut
>
> > > The problem I found with env was that the shell incorrectly passes args to
> > > env:
> >
> > The shell DOES pass args correctly. RTFM (info bash):
> >
> > "The arguments to the interpreter consist of a single optional
> > argument following the interpreter name on the first line of the script
> > file, followed by the name of the script file, followed by the rest of
> > the arguments."
> >
> > >
> > > % head -1 t348.sh
> > > #! /usr/bin/env perl -w
> > > % ./t348.sh
> > > env: perl -w: No such file or directory
> > >
> > > How does one get around this? Please don't say, "Don't use perl."
> >
> > Just write some wrapper and use
> > #!/your/wrapper
> >
> > wrapper will be runned as
> >
> > wrapper 'name_of_your_script'
--
Erdmut Pfeifer
science+computing gmbh
-- Bugs come in through open windows. Keep Windows shut! --
Reply to: