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

Hi all, I downloaded perl and Apache. I want to write a simple cgi script, but I don't what to write for the bang line. I would know what to write in a unix environment, but this is windows. Basically the script that I am writing is not being recognized as a perl script. Any assistance would be much appreciated!!
  • Comment on Serious newbie needs some help with a cgi script on a windows platform

Replies are listed 'Best First'.
Re: Serious newbie needs some help with a cgi script on a windows platform
by Popcorn Dave (Abbot) on Jun 14, 2005 at 05:34 UTC
    The first thing you're going to need to do is to set up your Apache on your box. I did this to do some CGI work on my laptop but I opted for using Apache 1.3 instead of 2.0.

    There are a lot of good tutorials on line ( Google is your friend ) to help you get it set up.

    As far as my shebang line it looks like this: #!c:/perl/bin/perl.exe -T -w

    HTH!

    Useless trivia: In the 2004 Las Vegas phone book there are approximately 28 pages of ads for massage, but almost 200 for lawyers.
Re: Serious newbie needs some help with a cgi script on a windows platform
by Anonymous Monk on Jun 14, 2005 at 05:19 UTC
Re: Serious newbie needs some help with a cgi script on a windows platform
by Robertn (Hermit) on Jun 14, 2005 at 05:42 UTC
    Hi, Since Windows runs by file association make sure your script has a pl extension ie test.pl Windows should then find the Perl compiler for you.
    Your sole purpose in life maybe to serve as a warning to others.
      Windows may, but Apache (or more accurately, mod_cgi), on windows or other wise, reads the shebang line of any CGI script and uses that program to execute.

      (Well, on linux it may not actually read the shebang, it may just pass it to the kernel program executing dealy thingy. But on windows it reads the shebang.)
      While Robertn' observation is true (within limits) for running perl scripts from the Windows command line (but note that it's perfectly possible to run
      C:/perl foo.cgi
      too), in the OP's situation, the Apache configuation determines the required file_type_extension for the script... which may be .cgi, .pl or either.
Re: Serious newbie needs some help with a cgi script on a windows platform
by elbee (Initiate) on Jun 14, 2005 at 06:09 UTC
    Thanks all. Now I know what the shebang line should look like! All this information is very helpful! Here is my code. It's a simple enough script. The problem is that when I bring up the script in a browser, I see a brief glimpse of a dos window and then it does nothing. I am not seeing any HTML generated.

    #!C:\perl\bin\perl.exe -w
    print "Content-type: text/html\n\n";
    print "<HTML>\n";
    print " <HEAD>\n";
    print " <TITLE>CGI Output</TITLE>\n";
    print " </HEAD>\n";
    print " <BODY>\n"; print " This is a response to your HTTP request
    \n";
    print " </BODY>\n";
    print "</HTML>";

      Hi elbee,

      I copied and pasted your code and saved it in a file name "cgitest.pl" and ran it as:

      http://127.0.0.1/cgitest.pl

      On Windows XP, Apache 2.0.53

      No problem, the page was displayed.

      Did you set up the Apache config file correctly?

Re: Serious newbie needs some help with a cgi script on a windows platform
by gube (Parson) on Jun 14, 2005 at 05:29 UTC