Wrapper on magic line?

N

Nilsson Mats

Hi!

I have an intresting problem for our programming community on Solaris.

I want to develop an environment where:
1) The developers shouldn't need to bother about which Perl version to use.
2) When the Perl version is changed in a controlled manner, the change should be instant.
3) For developers whose scripts fails after a Perl version change, there should be a roll-back possibility.

The infra structure in our department provides a cornucopia of Perl versions.
These are installed under eg. /app/perl/5.8.1/bin/perl
Furthermore, to support a specific version of Perl you have to run a script that modifies
your $PATH so that that specific Perl is found first in the PATH.


Some solutions that I have tried:


Solution 1:
Put the explicit path to your Perl interpretator as the magic line, eg:
Of course, you have to run the script that modifies your PATH prior to the script execution.

A script example:
#!/app/perl/5.8.1/bin/perl
printf "Hello, World!\n";

The drawback is that you have to update gazillions of magic lines when wechange to a new Perl version.


Solution 2:
Use a symbolic link to point to your current Perl version.
Still you have to run the script that modifies your PATH prior to the script execution.

A link example:
ln -s /app/perl/5.8.1/bin/perl /home/foobar/current_perl

A script example:
#!/home/foobar/current_perl
printf "Hello, World!\n";

The (smaller) drawback is that you have to edit the magic line if you deliberately want to override the Perl version.


Solution 3:
Use a wrapper that selects a Perl from the path.
Still you have to run the script that modifies your PATH prior to the script execution.

A script example:
#!/usr/bin/env perl
printf "Hello, World!\n";

If you don't like the selected Perl you can re-modify your PATH an continue.


Additions requirements:
When investigating this I found that you sometimes want to save your scripts in a CM-system,
eg. ClearCase. Furthermore you want to execute old verions of a script with that old Perl version that
exixtsed when it was developed.

Solution 4: (A combination of 2 and 3)
First you have a symbolic link in your CM-system that points to your selected Perl version.
This link is baselines along with the script source.

A link example:
ln -s /app/perl/5.8.1/bin/perl /vobs/foobar/current_perl

Secondly, you have a better wrapper that you put in the magic line:

A script example:
#!/vobs/foobar/perlwrapper
printf "Hello, World!\n";

The wrapper does ths following:
1) Checks if the environment (PATH etc.) is compatible with the Perl thatis pointed to by the
symbolic link.
2) If not, the environment is adjusted, using the script mentioned above.
3) Starts Perl.

Now my problem:
Where to find info of how to write such a wrapper.

--
Hälsningar/Regards,
-----------------------------------------------------------------
Mats Nilsson
ENEA Embedded Technology AB,Box232,Nytorpsv. 5,183 23 TÄBY SWEDEN
(e-mail address removed) http://www.enea.se +46850714626 +46709714626
(e-mail address removed) http://www.algonet.se/~gafvelin +4687201233
PGP 0x9EC47877 40D5AB62551ED1A0DEDE1FFBCF0F5B2D9EC47877
PGP 0x91BAB71D DEF5B01307C484C31CEE15DEE345166891BAB71D
PGP 0x5DA31679 18449D0BE17C96C9D440CA96CF8BC0E0
-----------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top