?
Solved

"Redirecting" a Shebang Line

Posted on 2011-10-02
5
Medium Priority
?
757 Views
Last Modified: 2012-05-12
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.
0
Comment
Question by:RobbieSnr
  • 3
  • 2
5 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 36901101
Rename the perl executables to perl-5.8 and perl-5.12 respectively.  Create a soft link /usr/bin/perl pointing to the version you want to use.
0
 

Author Comment

by:RobbieSnr
ID: 36902023
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.
0
 

Author Comment

by:RobbieSnr
ID: 36902463
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.
0
 

Author Closing Comment

by:RobbieSnr
ID: 36902466
A very simple solution to my problem.
0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 36902748
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!
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If your site has a few sections that need to be secure when data is transmitted between the server and local computer, such as a /order/ section for ordering or /customer/ which contains customer data, etc it would of course be recommended to secure…
Do you come here a lot? Are you lazy like me and don't want to go through the "trouble" of having to click your Dock's Safari icon and then having to click your Experts Exchange Favorites bookmark to get here? Well then this article is for you.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question