Link to home
Start Free TrialLog in
Avatar of RobbieSnr
RobbieSnrFlag for United Kingdom of Great Britain and Northern Ireland

asked on

"Redirecting" a Shebang Line

I produce Perl CGI scripts for some websites. Some of these scripts were written some time ago when I was using WindowsXP with ActivePerl version 5.8 installed. When I moved over to a Mac a few years ago I installed the same ActivePerl version on the Mac and continued to use it to develop new scripts, changing PATH to point to that version of Perl - the live server that is running these scripts is still on version 5.8.

Everything works fine when I’m working locally with these scripts. However I use MAMP to set up virtual hosts for the various websites so that I can test the scripts on my server before uploading them to the live one. The shebang line in these scripts is the usual /usr/bin/perl one so when I run the scripts on my server it uses the Mac’s inbuilt version of Perl, which for Lion is 5.12. My problem is that I have a module installed on the ActiveState Perl version 5.8 that I’ve not been able to install on the Mac’s 5.12 using CPAN, possibly because although I’ve changed the PATH variable to remove the path to 5.8 it is somehow still getting confused about which version of Perl it is trying to add the module to. I've installed the Developer Tools for Lion so this is not the problem.

I can get round this by changing the shebang line to point to Perl 5.8 but then I’ve got to remember to change it back again before I upload it to the live server. I was wondering if there is any way, by changing the Apache settings or otherwise, of leaving the original shebang line and arranging for my server to use Perl 5.8 rather than the inbuilt 5.12.
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RobbieSnr

ASKER

Many thanks for this suggestion.

I've just got one question. I suppose that in case the renaming of the inbuilt perl-5.12 caused any problems with the Mac OS I could leave it as it is, just renaming the perl-5.8 one? I'll give this a try.
I've now got this working, many thanks.

I'm very much a beginner as far as bash is concerned and I see that I have to get rid of /usr/bin/perl before I can set up the symbolic link. In fact the /usr/bin/ folder already has a perl5.12 entry. I've set up the link and my shebang line is now redirecting to Perl 5.8 all right. A lot easier than I thought this would be - great.
A very simple solution to my problem.
And if you ever need to put the 5.12 back into service, just change the soft link to point to the other version.  Good luck!