Link to home
Start Free TrialLog in
Avatar of JacquesDP
JacquesDP

asked on

Having .cgi treated as Perl scripts

Hello,

I am using a local setup with native Windows versions of Apache and Perl, in order to work on web sites locally, which I then upload to my Unix web host. It is working fine, but there is one last thing to solve.

I am using some files with .cgi extension (in the setup of my web host, these can sit anywhere, no cgi-bin directory is used), which happen to be Perl scripts (all of them).

Obviously it won't work "out of the box", since the #! line needed on my Unix host won't help Windows Apache to find Windows Perl.

So what I was thinking to do was to instruct Windows Apache (local) to treat all .cgi scripts as Perl scripts. Had no luck doing this so far, though.

Could anyone tell me the necessary and sufficient changes to be done in httpd.conf to achieve that result (OR possibly provide another route to solve the same problem)?

Thanks!

Jacques

PS: FYI, I am using the Apache2Triad pack, pretty much out of the box (this is a packing of Windows Apache, and supporting Windows native software).
Avatar of JacquesDP
JacquesDP

ASKER

Note : the fact that my Perl CGI scripts end in .cgi is a contraint from my web host (i.e., I can't change them to .pl).
ASKER CERTIFIED SOLUTION
Avatar of ronan_40060
ronan_40060
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
Hi Ronan,

Thanks for your answer, however it doesn't really address my question.

First, my goal is not to have .pl files interprteted as Perl scripts, but .CGI files to be interpreted as Perl scripts.

Your way 1 is not useful regarding the .pl file (I don't have .pl file, since my web host forces me to have Perl script with the .cgi extension).

Your way 2 is what I need to avoid, in order to be able to upload the file untouched on my Unix host (see my initial message).

Your way 3 won't work either, since the file is .cgi and not .pl.

Another bit of information is that my local, windows native version of Perl is ActivePerl.

Thanks,

Jacques
OK
Then just put
 the following directive to httpd.conf:
  AddHandler cgi-script .cgi
This tells Apache that files with extensions .cgi  must be executed.

let me know
Ronan
Hi Ronan,

I have this already. But it will only work if I have a correct shebang line at the beginning, namely

#!C:/apache2triad/perl/bin/perl.exe

But if I put that, then I cannot upload my files to my Unix web host.

Hence my question.

Thanks,

Jacques
Well on Unix host
your path would change you can not use the windows path to a Unix Host
change the path to Unix perl path in shebang line
Hi Ronan,

The thing is, I want the SAME files (unchanged) to work on both plaform (the upload is an automated and frequent process on many files). This is really what my question is about.

The Unix  Apache will rely on the shebang line, but I can probaly tweak my local Windows Apache config so that .cgi files be treated as Perl script regardless of the  (Unix) shebang line, can't I?

Jacques
As far as I know you need to have your cgi files named as .pl files to be treated as perl scripts.
Also you have Active Perl installed on your windows. you need to have your cgi named as .pl
As I said above, this is not an option for me, since my web host forces me to have .cgi extension on all my scripts. I am pretty sure there is an easy solution. If no one can offer it to me here, I will do more research on my side.
As far as I'm concerned, the question has not been answered. (In fact, I now change manually the shebang line before uploading, and what I was asking is how to avoid that, and have the exact same .cgi perl script work on both platforms.)
SOLUTION
Avatar of periwinkle
periwinkle
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
Hi periwinkle,

I can have a .pl perl script on the web host (this is a new info, I was ruling this out earlier). Now, can I manage for this same .pl perl script, with the same shebang line (necessarily wrong for one of the two platforms), to work on both platform?

Thank you

Jacques
SOLUTION
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
Heh. This works :-)

Though this does not answer my original question in the way it was originally phrased, it still sort of solves my problem. I am sharing the points between you both.

Thanks a lot, both for the original answer from Ronan and the further explanation from periwinkle.

Jacques
Jacques - Glad to hear that this solves your problem - good luck with your work, and best wishes for a happy holiday!