most kernels don't support having a #! line in a script that points to another script

While this is correct in general, it's maybe worth pointing out that newer versions of the Linux kernel (as of 2.6.27, IIRC) can actually handle this fine (finally!).   I.e., things like these do in fact work:

---  perl-wrapper  ---

#!/usr/bin/perl my $choice = splice @ARGV,1,1; exec '/usr/local/perl/5.14.1/bin/perl', @ARGV if $choice == 14; exec '/usr/local/perl/5.12.3/bin/perl', @ARGV if $choice == 12; exec '/usr/local/perl/5.10.1/bin/perl', @ARGV if $choice == 10; exec '/usr/local/perl/5.8.8/bin/perl', @ARGV;

---  wrap-test.pl  ---

#!/home/eliya/tmp/perl-wrapper print "$] -- @ARGV\n";
$ ./wrap-test.pl 14 foo bar 5.014001 -- foo bar $ ./wrap-test.pl 12 foo bar 5.012003 -- foo bar $ ./wrap-test.pl 10 foo bar 5.010001 -- foo bar $ ./wrap-test.pl 99 foo bar 5.008008 -- foo bar

(the technique to use the first arg as version selector is of course just for demo purposes)

P.S.: side note for anyone playing with this: make sure you have the string "perl" in the shebang line, or else you'll get surprising effects like endless exec loops... — see perlrun for why (search for the word "bizarre").


In reply to Re^3: wrapper script to conditionally exec different perls? (#!->#!->#!->...) by Eliya
in thread wrapper script to conditionally exec different perls? by stackspace

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.