By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,691 Members | 1,134 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,691 IT Pros & Developers. It's quick & easy.

Wrapper on magic line?

P: n/a
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
Ma**********@enea.se http://www.enea.se +46850714626 +46709714626
ga******@algonet.se http://www.algonet.se/~gafvelin +4687201233
PGP 0x9EC47877 40D5AB62551ED1A0DEDE1FFBCF0F5B2D9EC47877
PGP 0x91BAB71D DEF5B01307C484C31CEE15DEE345166891BAB71D
PGP 0x5DA31679 18449D0BE17C96C9D440CA96CF8BC0E0
-----------------------------------------------------------------
Jul 19 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.