Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Need help with Perl in IIS setup

by jmboniface (Initiate)
on Jan 06, 2006 at 21:02 UTC ( [id://521635]=perlquestion: print w/replies, xml ) Need Help??

jmboniface has asked for the wisdom of the Perl Monks concerning the following question:

I am taking a class on Perl and trying to get it working on Windows Server 2003 running IIS6. I am using Visual Interdev as a development environment. I installed the latest version from ActivePerl. The installation, I believe, went well. Never any issues encountered. So, I created a small test.asp file with the following code:
<HTML> <HEAD> <META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0"> <TITLE></TITLE> </HEAD> <BODY> <form ACTION="scripts/showme.pl" method="Post" id=form1 name=form1> <input type="submit" value="Button" id="button1" name="button1"> </form> </BODY> </HTML>
Then, I created a folder in my project called Scripts. I created a .pl file with the following code and placed it in the Scripts folder.
#!C:\Perl\bin\perl.exe -wT use strict; use CGI ':standard'; print "Content-type: text/html\n\n"; print "Show me the money";
When I first ran the test.asp file and clicked the submit button, I was presented with the following error:   The specified CGI application misbehaved by not returning a complete set of HTTP headers. I found something on the internet that suggested that I change the mappings in IIS to use perlis.dll instead of perl.exe, so I did that. If I now run the test.asp, click the button, the resulting output in the browser is:
Content-type: text/html 'c:\inetpub\wwwroot\weblanguages\scripts\showm +e.pl' script produced no output
I found something else that suggested that I did not need the first line when using Windows. So I actually removed the first three lines from the .pl file, and when I run it without those three lines, the output is:
Content-type: text/html Show me the money
So here is where I stand. I can not figure out how to get the application to stop printing the "Content-type: text/html" part of the output. I am under the impression this is the line used to interpret what is to be displayed and that the browser should not print this line out. Does anyone here have any suggestions on where I can go to find a solution to this, or does anyone here already know the solution? I would be very thankful for any help

2006-01-06 Retitled by jdporter, as per Monastery guidelines

Replies are listed 'Best First'.
Re: Need help with Perl in IIS setup
by abcde (Scribe) on Jan 06, 2006 at 21:16 UTC

    Hello there, welcome to perl monks

    The print "Content-type: text/html"; line is used on Unix servers to tell the browser what it should display, and it should always come before any text. However, it appears that IIS or ActivePerl is adding this line for you.

    From what I understand, your code looks like this:

    print "Content-type: text/html\n\n"; print "Show me the money";

    In which case, the browser has already got a Content-Type header from IIS, and your script is sending it another one! Try removing it, and see if that fares any better.

    One more thing - the 2nd and 3rd lines you removed, you should not have done - strict makes your code easier to debug, and CGI allows you to use forms and web-page things, so it is best to add them back in.

    Hope this helped

      hello
      is not for this reason i put
      use CGI qw /:standard -nph/;
      at the top of my CGI?

      Lorenzo
Re: Need help with Perl in IIS setup
by beachbum (Beadle) on Jan 06, 2006 at 22:19 UTC

    Also, if you're already familiar with ASP, that is available through PerlScript. You can create a showme.asp file something like this: (the Active state documentation that's installed by default has more info). Also, not that it matters in this case, but the code is compiled through isapi and a perl dll instead of loading perl.exe for each page, which should make it more efficient.

    <%@LANGUAGE=PERLSCRIPT%> <HTML> <% $Response->write("Show me the money"); %> </HTML>
Re: Need help with Perl in IIS setup
by simon.proctor (Vicar) on Jan 09, 2006 at 09:56 UTC
    When using Perl based CGI on IIS you map the .cgi or .pl extension to the Perl executable. The mapping looks something along the lines of:
    pathtoperl %s %s
    So you don't need the #! (or shebang) line. That is why on IIS you were having problems. Normally this is done for you when you install ActivePerl on Windows hence why you didn't see it. Check out the ActivePerl docs to see it (assuming you are using ActivePerl of course!).

    This mapping is the same as for ASP, SSI (etc). There is a properties part of your web config inside IIS that configures each file extension for the server and tells it what to load against it. In the case of ASP, there are a host of dlls (etc) that IIS loads.

    I suggest you read up on this as it is always good to have a closer idea of how your webserver handles your apps (and others).

    HTH, S

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://521635]
Approved by kirbyk
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (8)
As of 2024-04-20 00:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found