in reply to Re: using "#!/<perlpath>/bin/perl" to exec a shell script?
in thread using "#!/<perlpath>/bin/perl" to exec a shell script?
## common shared automount: /<perlpath</bin/perl -> /usr/local/perl588 ## i386: /usr/local/perl588 -> /<perlpath>/i386/bin/perl ## sparc: /usr/local/perl588 -> /<perlpath>/sparc/bin/perlThis 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...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: using "#!/<perlpath>/bin/perl" to exec a shell script?
by graff (Chancellor) on Oct 04, 2007 at 04:57 UTC |