Forum Moderators: phranque
I installed an Apache Webserver 2.0.50-win32 and an ActivePerl 5.8.4.810-MS on a Windows XP (SP2) machine.
After installation I could see the Apache test page with my browser. Then I tried to call the little Perl example in cgi-bin with [localhost...] My browser asked me to download the file ( I did it, content was the output from the pearl script ). Hmm ... I tried it from another machine in the network and from there it worked fine, means I got the output from the pearl file in the browser window.
I searched the Internet for this problem and got a lot of different descriptions of the same problem but not a satisfying answer. Very interresting was the comment from somebody that a call with a trailing / works fine ( [localhost...] ) That works on my machine too. All other hints to make changes in the default apache configuration failed.
Then I played with file associations. The Perl installation made an association between .pl files an the perl.exe file. I deleted this association and now the script was running fine.
Now I installed Perl on the other machine on the network, including the file association, and this caused the problem on this machine too. Every browser call to [192.168.0.1...] resulted in a download question. I deleted the file association and it worked again.
How can I control this? I understood, all people who have not installed Pearl and have no file association to .pl can see my webpage correctly but if somebody have installed Pearl with a file association ( to pearl.exe or to an editor ) it will result in a download question. Is there a possibility to influence this behaviour from the server site?
Thanks a lot for your help
Henning
Welcome to WebmasterWorld!
This sounds like a simple undefined-MIME-type problem.
Try adding the following line to any PERL script you have which outputs HTML to the browser. This line must be the first "print" statement in the script:
print("Content-type: text/html\n\n");
Jim
The Perl script printenv.pl I´m using is original from Apache. It is an example comming with the Apache packet (apache_2.0.50-win32-x86-no_ssl.msi).
When you look into the source code you can see that it starts with
print "Content-type: text/plain\n\n";
Ok, I changed this to text/html and, indeed, the Browser is not starting a download. But the output looks not very fine. The perl script is not producing html-code, it`s plain text. When you start the perl script on the command line you see the environment line by line, there are no html tags except the Content-type.
Is it possible that my IE 6 (SP2) doesn`t understand plain text in combination with a file association? It seems that this is a IE specific problem. No file association to .pl -> no problem.
Do you have another idea?
In most uses of PERL to generate Web content, the script and its .pl extension are 'not visible' to the user. That is because the PERL script is called from an include in an HTML page, or because mod_rewrite is used to make the PERL script look like an HTML page. If you wish to run PERL on your machines, but also be able to view their output with a browser, then I'd suggest using one of those methods.
Jim