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

Hi , I have installed activeperl. I wanted to test cgi scripts. I have already installed MS personal web server. It already had cgi-bin directory. Just I put the program tryit.pm came with activeperl into c:\inetpub\wwwroot\cgi-bin and typed at address in browser http://localhost/cgi-bin/tryit.cgi. But I am not getting any thing I am expecting. Is it possible to test cgi scripts with MS PWS? Or any mistake I have done in invoking cgi script? Can you pl. help me? Thanks Ashok

Replies are listed 'Best First'.
(Ovid) Re: testing cgi scripts
by Ovid (Cardinal) on Nov 13, 2000 at 11:37 UTC
    You'll have to be a bit more descriptive. When you say that you're not getting what you expected, what are you getting? Here's a couple of things that you might want to check (in no particular order):
    • Is the Web server actually running?
    • Is your shebang line correct? Typically with ActivePerl it's something like this:
      #!c:/perl/bin/perl.exe -wT
      The -wT are optional and shouldn't affect whether or not your script is running, but they are a good habit to get into. Make sure that the path to your Perl executable matches the path on the shebang line!
    • Can you run the script from the command line? That's important! If you can't, you won't be able to run it through a browser, either.
    • Check your documentation. Some servers will not run scripts unless you have a .cgi extension. Others will not run them unless they are in a particular directory.
    • Does entering http://localhost actually call up the default home page? If not, the problem is with the server installation.
    • Are you running NT and possibly having an issue with permissions?
    • Are you outputting the Content-type: header before other headers?
      use CGI qw/:standard/; print header;
    • Have you verified that all of your systems calls return true? For instance, don't open a file unless you check the value of $!.
      open FILE, "<$somefile" or die $!;
    • Have you checked the server's error logs? What do they say?
    • Have you read the ActivePerl FAQ?
    Cheers,
    Ovid

    Join the Perlmonks Setiathome Group or just go the the link and check out our stats.

Re: testing cgi scripts
by neophyte (Curate) on Nov 13, 2000 at 13:51 UTC
    Generally it is possible to test cgi-scripts with PWS, but you first have to go to the administration interface, and tell PWS where it can find Perl and I even had an installation, where I had to tell PWS that it may indeed execute files that lie in cgi-bin.
    Personally I find Apache (for win32) far easier to handle. Even though it has this large config-file, but I found the documentation within that file to be enough to get it running for local cgi-testing.

    For ease of configuration I can also recommend Xitami or OmniHTTPd.

    neophyte

Re: testing cgi scripts
by Fastolfe (Vicar) on Nov 13, 2000 at 18:45 UTC
    You probably have to associate the .pl (and .pm?) extensions with ActivePerl in your web server configuration. But this may be a simple problem of extensiosn. CGI scripts don't just automatically run when you give it an extension of .cgi. If your CGI script had a .pm extension, that's how you should be requesting it. But a word of warning: .pm files are modules, not stand-alone scripts. It's weird that you would be running a .pm file as a CGI script. Are you sure it shouldn't be .pl?
Re: testing cgi scripts
by wardk (Deacon) on Nov 13, 2000 at 20:36 UTC
    Just I put the program tryit.pm came with activeperl into c:\inetpub\wwwroot\cgi-bin and typed at address in browser http://localhost/cgi-bin/tryit.cgi.

    One thing right off: you mention tryit.pm, but the URL you cite is looking for tryit.cgi