Page 1 of 1

Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 08:14
by sborder
I have xampp and the perl addon installed. It's working but I need to change the path to perl to #!/usr/bin/perl instead of #!"G:\usr\perl\bin\perl.exe".

This is a test server and all of the scripts that I work with have #!/usr/bin/perl as the shebang line. So it's important to keep that line the same in the scripts.

This is on my windows xp sp2 pc.

I'm not quit sure where to go from here.

Thnks
Steve

Re: Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 08:44
by Izzy
I found this in my KB from an earlier post which may seed some ideas:
viewtopic.php?p=116505#p116505
Izzy's KB wrote:Hi, I had a suggestion for a better place for XAMPP to install Perl. I
am sure this has been suggested before but C:/usr/bin/perl is the better
idea than C:/xampp/perl. I personally created a usr in C:/ folder and
moved my perl folder from C:/xampp/perl to C:/usr and it helped me a
lot.

In Perl/CGI, you have to do

#!/usr/bin/perl
for Linux and most other servers on the web, so what you would have to
do with XAMPP is

#!/xampp/perl
which makes things a whole lot harder when you're using XAMPP for
testing code on your home computer just to upload it to your actual web
server later as I do.
You may have to use #!usr/bin/perl.exe which will work with XAMPP and your remote server if you follow the above idea.

Re: Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 14:09
by sborder
Believe it or not, I had moved the bin directory up one level so the path would be correct. But then I tried the xampp control panel and I was not able to start the aphache server.

But I will look at this again.
Will let you know.

Thanks
Steve

Re: Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 14:14
by Izzy
If Apache won't start then run apache_start.bat file and see the message returned, it will hold the clue.

Also check out the apache\logs\error.log file.

May be you would need to remove perl and reinstall the addon again to the new location as there is a perl.conf and a startup.pl file in the apache\conf\extra folder that may have to be edited or deleted to reflect your new location - I have not tested this hack but I was assured that it worked, experiment and see how it pans out.

Re: Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 15:20
by Wiedmann
I had moved the bin directory up one level so the path would be correct.

Revert this change.

This is a test server and all of the scripts that I work with have #!/usr/bin/perl as the shebang line. So it's important to keep that line the same in the scripts.

http://httpd.apache.org/docs/2.2/mod/co ... etersource

Re: Changing the path to perl to conform to the cgi script

PostPosted: 14. February 2009 23:11
by Izzy
@Steve

Please move the bin folder back to where it was originally before attempting the below test.


I decided to test the above hack for myself so I could confirm what had already been established, that it indeed worked.
(Your paths may be different so adjust as required).


1. First I copied the contents of the G:\xampp\perl folder to a newly created G:\usr folder.

2. Renamed the G:\xampp\perl folder to G:\xampp\perladdon

3. Changed the path in G:\xampp\apache\conf\extra\perl.conf file from /xampp/perl to /usr on the first line only.

4. Change the shebang in G:\xampp\cgi-bin\perltest.cgi from #!"G:\xampp\perl\bin\perl.exe" to #!/usr/bin/perl.exe

5. Started Apache - it started without errors.

6. Went to http://locahost/cgi-bin/perltest.cgi

The perltest.cgi worked as expected and returned the expected script's contents:
CGI with MiniPerl
CGI with MiniPerl is ready ...


7. I then tested it with several of my production cgi scripts after changing the shebang and all worked as expected at localhost - not tested on a remote server but they should work fine as the shebang is now the same as for a remote apache server.


So after testing the above I can see no reason at this time that it would not work for you.

Let me know if you can follow the above and if it worked for you with the result that you was seeking.

Re: Changing the path to perl to conform to the cgi script

PostPosted: 15. February 2009 00:02
by sborder
Izzy - Thanks !! It works great.

The only difference was that I already had xampp installed in the "G:/usr" directory.
I just changed the directory when I used the installer.

Now if this could become an option when installing it would save some mionr main. :)

Anyway thanks, your help is appreciated.

Steve

Re: Changing the path to perl to conform to the cgi script

PostPosted: 15. February 2009 00:11
by Wiedmann
Izzy - Thanks !! It works great.

I hope you will never update XAMPP and the Perl AddOn... (you must copy Perl every time you update XAMPP) But fine it's working for you :-)

As I post above above:
The preferred way (from apache.org) is to use ScriptInterpreterSource (one line in "httpd.conf" and one entry in the Windows registry). Or just make a symlink (no other changes are necessary) .

Re: Changing the path to perl to conform to the cgi script

PostPosted: 15. February 2009 00:58
by sborder
I am unsure of playing in the registry. This is on my good pc and I would hate to mess things up. But I do agree your way would be better and if I had more experience with the registry I might try your way.

I am going to setup a test server (for agoracart) with a different box in a couple of months, so this is just a temporary fix.

Thanks
Steve

Re: Changing the path to perl to conform to the cgi script

PostPosted: 15. February 2009 01:04
by Wiedmann
I am unsure of playing in the registry.

It's just a simple file association, which you can also make in explorer. Nothing special.

(Making it in the registry it's just easier to explain for me, because I don't know the English explorer menu names.)