thparkth has asked for the wisdom of the Perl Monks concerning the following question:
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
/nfs/perl/5.10/centos4/bin/perl
and
/nfs/perl/5.10/centos5/bin/perl
(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
/nfs/perl/5.10/bin/perl
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:
#!/bin/sh . /etc/host.conf exec /nfs/perl/5.10/${HOST_PLATFORM}/bin/perl "$@"
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?
|
|---|