http://www.perlmonks.org?node_id=976847

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

I have strawberry perl installed on a windows 2003 server running IIS 6

I am tying to run a cgi script but it seems like it is trying to be downloaded to my browser. Note this script creates a web page with html.

when i try to run the script from IE I get

Internet explorer can not download test.pl from <servername> Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please tr +y again later.

This is a very simple script.

Here it is.

#!c:\strawberry\perl\bin\perl.exe use strict; use CGI; my $test = new CGI; print $test->header("text/html"),$test->start_html("Perl Test"); print $test->h1("Perl is working!"); print $test->end_html;

Can someone give me a hint?

Help!

Replies are listed 'Best First'.
Re: CGI SCRIPT
by davido (Cardinal) on Jun 18, 2012 at 15:46 UTC

    There is nothing wrong with your script, so it's really not so much a Perl issue as it is a configuration issue.

    Is your server configured to recognize this script as an executable script rather than as static content? Is this script readable and executable by the web server (permissions)? Those are a couple of obvious places to start.

    And keep in mind that the server maintains a log of error messages that the browser never sees. Find that log and read what's in it. The messages will be enlightening.


    Dave

Re: CGI SCRIPT
by thomas895 (Deacon) on Jun 18, 2012 at 15:47 UTC
Re: CGI SCRIPT
by ww (Archbishop) on Jun 18, 2012 at 15:54 UTC
    First hint: use <c>...</c> around code (update : which was not the case as initially posted. </update>)

    Second, et seq: There's nothing in the script you showed to explain this commonplace problem. So, (granting that some/all may be irrelevant under IIS) is the script executable under IIS6; is it in the right place (/me suspects the hashbang gives a path that's incorrect from the server's perspective); does the server have permissions to execute anywhere in c:\strawberry\perl\bin\ and, specifically, in whatever dir your script is stored? Is the server actually running ("The requested site is either unavailable or cannot be found.") and last, but definitely not least, what gives you the impression "it seems like it is trying to be downloaded to my browser...?"

Re: CGI SCRIPT
by zentara (Archbishop) on Jun 18, 2012 at 18:22 UTC
    Another common mistake is to put your cgi script in the html root directory, instead of the cgi-bin directory. Most servers are set up to serve out anything in html root by just delivering the page or file. It will only be executable in your cgi-bin directory, or any directory setup in the server configuration file to execute cgi scripts.

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh
Re: CGI SCRIPT
by Anonymous Monk on Oct 08, 2012 at 21:19 UTC
    Sorry but I was pulled off this. Now looking at this again. I am now getting CGI Error The specified CGI application misbehaved by not returning a complete set of HTTP headers.