I like this idea. Basically you have the common path, linked through the local machine (and hence machinetype) to another link to the actual perl binary:
## common shared automount:
   /<perlpath</bin/perl -> /usr/local/perl588
## i386:
   /usr/local/perl588 -> /<perlpath>/i386/bin/perl
## sparc:
   /usr/local/perl588 -> /<perlpath>/sparc/bin/perl
This would work if I could get our admin team to add these links by default in the standard setup of our servers. We have *thousands* of sparc servers however, running both Solaris9, and Solaris10, and about a hundred so far of the i386 servers. Unfortunately I can't modify the standard unix file structures.

The basic mystery here is how to trick the unix kernel into thinking that a shell script is a legitimate binary file that returns the appropriate "magic number". The "magic number" apparently is an evaluation of the first two bytes in the file. Hence if the first two bytes of a file are #!, the file is a shell script; if they're %!, it's a postscript file, etc. Files that are "exec"-able from the kernel have "0x75" "E" "L" "F" as the first four characters.

The more I discuss this, the more I'm convinced it's not possible to do what I'm trying to do. The real solution appears to be to just change all our scripts once, to invoke perl using

   #!/bin/sh -- # -*- perl -*-
   eval 'exec <perlpath>/bin/perl -S $0 ${1+"$@"}'
     if 0;
This solution is actually relevant now that we really can't rely on the #! direct reference to the interpreter.

But if there's some really really deep dark ancient magic that can work here, I am your humble adept...


In reply to Re^2: using "#!/<perlpath>/bin/perl" to exec a shell script? by cadphile
in thread using "#!/<perlpath>/bin/perl" to exec a shell script? by cadphile

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.