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

The first line in the cgi files on apache(linux) is #!/usr/bin/perl. what should it be modified to if we want to run cgi scripts on MS Personal Web Server. I am getting internal server errors.

Replies are listed 'Best First'.
Re: what instead of #!/usr/bin/perl
by Chady (Priest) on Apr 09, 2001 at 11:38 UTC

    AFAIK, when using PWS for Windows, there is no importance what to use as a path, you could just write #!perl and it will work, but you have to modify the registry; here's a good node to read about that


    He who asks will be a fool for five minutes, but he who doesn't ask will remain a fool for life.
(Ovid - setting up a Web server) Re: what instead of #!/usr/bin/perl
by Ovid (Cardinal) on Apr 09, 2001 at 16:00 UTC

    If you decide to go with Apache for Windows, you can read this link for step-by-step instructions on how to set it up.

    I haven't used Personal Web Server, that I recall, but it may be a case of associating the .cgi extension with the Perl executable. Personally, I don't like that as it typically requires editing the registry to manually add the -T switch to turn on taint checking. Otherwise, if the shebang line (#!/usr/bin/perl) is the problem, change it to the path of the Perl executable. It will then resemble something like the following:

    #!C:\perl\bin\perl.exe -wT

    The -wT, strictly speaking, isn't necessary, but the warnings are helpful when developing your code and the -T switch is essential when doing Web programming as it turns on taint checking. See perlsec for details.

    Last comment: if you are getting internal server errors, what do your Web server logs say? Find them and they'll probably tell you exactly what the problem is.

    Cheers,
    Ovid

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

      Actually you probably have used PWS but don't realize it. But for two registry entries, PWS is (or at least used to be) IIS. I don't know about Windows 2000, but with NT those two entries were the only difference between NT Workstation and NT Server.

      Why 2 entries you ask? Well when there was just one they had too many problems with people just flipping it. So they made it 2 as a check, and if they don't match your computer will BSOD on boot. (To be sure, changing them violates your license agreement, so Microsoft does have a point...)

      Anyways, any time you see PWS just say what you would think for IIS and it is probably going to be correct. It is the same software. Same binary. Just different configuration settings.

Re: what instead of #!/usr/bin/perl
by ColtsFoot (Chaplain) on Apr 09, 2001 at 10:42 UTC
    I can only suggect trashing MS Personal Web Server in place of Apache for
    a Windoze platform then, follow the inline documentation within the httpd.conf file
    # # Apache parses all CGI scripts for the shebang line by default. # This comment line, the first line of the script, consists of the sym +bols # pound (#) and exclamation (!) followed by the path of the program th +at # can execute this specific script. For a perl script, with perl.exe +in # the C:\Program Files\Perl directory, the shebang line should be: #!c:/program files/perl/perl # Note you _must_not_ indent the actual shebang line, and it must be t +he # first line of the file. Of course, CGI processing must be enabled b +y # the appropriate ScriptAlias or Options ExecCGI directives for the fi +les # or directory in question. # # However, Apache on Windows allows either the Unix behavior above, or + can # use the Registry to match files by extention. The command to execut +e # a file of this type is retrieved from the registry by the same metho +d as # the Windows Explorer would use to handle double-clicking on a file. # These script actions can be configured from the Windows Explorer Vie +w menu, # 'Folder Options', and reviewing the 'File Types' tab. Clicking the +Edit # button allows you to modify the Actions, of which Apache 1.3 attempt +s to # perform the 'Open' Action, and failing that it will try the shebang +line. # This behavior is subject to change in Apache release 2.0. # # Each mechanism has it's own specific security weaknesses, from the m +eans # to run a program you didn't intend the website owner to invoke, and +the # best method is a matter of great debate. # # To enable the this Windows specific behavior (and therefore -disable +- the # equivilant Unix behavior), uncomment the following directive: # #ScriptInterpreterSource registry #
    Hope this helps
Re: what instead of #!/usr/bin/perl
by c-era (Curate) on Apr 09, 2001 at 16:49 UTC
    You need to create an assosiation. To do this, open your 'internet service manager'. Right click on your web site and choose properties. Click on the 'Home Directory' tab. Next, click on the 'Configuration..." button. In the new window click the 'Add' button. In the 'Executable' field put the path to your perl install (mine is d:\perl\bin\perl.exe) and add two ' %s' after it like this 'd:\perl\bin\perl.exe %s %s'. Under the 'Extension' field put '.pl'. Click 'OK', 'OK', 'OK', then stop and start your web site. Now pws (or iis) will use perl for any files that end with '.pl'.
Re: what instead of #!/usr/bin/perl
by dws (Chancellor) on Apr 09, 2001 at 20:51 UTC
    Detailed instructions for teaching PWS that ".cgi" means "Perl" are in this node. And, should you desire to have -T working with IIS/PWS, see the discussion that starts in this node.