|Perl Monk, Perl Meditation|
Can I write a transparent shell wrapper to start the correct build of Perl?by thparkth (Beadle)
|on Feb 05, 2008 at 16:01 UTC||Need Help??|
thparkth has asked for the
wisdom of the Perl Monks concerning the following question:
This is really a shell question, not a Perl question, but for reasons that are hopefully obvious, it can't be done in Perl.
In our NFS environment we have various different platforms (Linuxes and AIX) sharing a common filesystem. It's useful to have central builds of certain programs - Perl being a good example, because it lets us have centrally installed modules too.
So let's say that we have
(The user environment is automatically set up so that the correct perl for their host is in the path.)
What I want to do is create a
which checks the platform of the current host, and starts the correct perl interpreter. I want it to work in a hash-bang line, and support command line parameters etc. Basically it should be invisible to the user that they aren't hitting the actual Perl binary directly.
I thought I had this working, with this script:
In fact, this seems to work on the majority of machines. But there are some machines where it doesn't work at all when used in a hash-bang line. Instead of starting perl and running the script with that, it tries to run the perl script through /bin/sh, with the entertaining but unproductive results that you would probably expect.
I can't see any pattern for which hosts work and which don't, though many have custom kernels which might be a factor.
Does anyone know of an alternative way to write this wrapper script which might be more reliable?