Click Here!
home account info subscribe login search My ITKnowledge FAQ/help site map contact us


 
Brief Full
 Advanced
      Search
 Search Tips
To access the contents, click the chapter and section titles.

Perl CGl Programming: No experience required.
(Publisher: Sybex, Inc.)
Author(s): Erik Strom
ISBN: 0782121578
Publication Date: 11/01/97

Bookmark It

Search this book:
 
Previous Table of Contents Next


Working with the NT Registry Editor

A caveat before we go any further: The Windows NT Registry stores information that NT programs need in order to run. Be very careful to precisely follow instructions when you change entries in the Registry, because if you make a mistake, you could bring your NT system to its knees.

IIS runs as an NT service, which is a program that generally starts automatically at boot-time and runs in the background. You will find IIS in the Registry folder that contains all of the currently defined NT services (see Figure 2.2):

   HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services


Figure 2.2:  The Registry SYSTEM folder has been opened.

Follow these steps to find the correct CGI directory:

1.  Double-click the Services folder to open it, then scroll down until you see an entry titled W3SVC (Microsoft’s turgid way of saying WWW Service).
2.  Double-click W3SVC and several folders will open, one of which is Parameters. Opening it reveals Script Map and Virtual Roots folders.


WARNING:  Windows NT programs depend on the Registry for information that, in many cases, is essential to their being able to run. Follow the instructions precisely, because the results will be very nasty if you inadvertently enter bad data into the Registry.
3.  Open the Script Map folder first and look in the right window. If you see no entry that starts .pl, click Edit and choose Add value from the drop-down menu.
4.  Figure 2.3 illustrates the dialog boxes that come up when you click Add value. Type .pl as the value (don’t forget the period) and click OK. Another dialog box comes up. In this one, type in the full path to your Perl interpreter.


Figure 2.3:  The Add Value dialog boxes

Services and Daemons

Services on Windows NT and daemons on UNIX are programs that run in the background (and are often brought to life at boot-time) that never impose on us with fancy graphical user interfaces or queries that we have to answer. They do their jobs silently and efficiently; the only time we notice them is when they’re not working.

The Web server is one of these programs. All of the httpd references to it in program names and directories in a UNIX system are acronyms for Hypertext Transfer Protocol Daemon.

5.  When you click OK this time, another line will appear in the right Registry Editor window, as illustrated in Figure 2.4.
.pl:REG_SZ:c:\perl\bin\perl.exe


Figure 2.4:  The Perl association


NOTE:  As in Skill 1, we have used an example path to the Perl interpreter that may not be the same as yours. Be sure to refer to your Perl interpreter or this won’t work.

You have now told the Web server that it should run the Perl interpreter to execute programs with the extension .pl.

You’re familiar enough with the Registry Editor by now to whip through the second step. Besides, you probably won’t have to add anything. Follow this step:

1.  Open the Virtual Roots folder. You should see something similar to Figure 2.5; this value is added by default in the IIS installation.


Figure 2.5:  The Registry’s Virtual Roots folder

Notice the /Scripts entry. The only thing that concerns us here is the directory path, which in the example is c:\Inet\Pub\scripts. This is the directory in which you will install and run your Perl CGI programs. You may change it if you like, but there is little reason to do so.


NOTE:  CGI programs are placed in certain directories for security. If all of the programs the Web server will run are in one place, the Webmaster can more easily see who’s running what and from where.

Setting Up UNIX-Style

On UNIX, configuring an HTTP server for CGI and Perl is pretty simple. The standard NCSA server gets its configuration information from a text file called srm.conf. Two lines in the file answer our concerns.

   ScriptAlias      /cgi-bin/                    /usr/local/httpd/cgi-bin
   AddType          application/x-httpd-cgi      .pl

The CERN server wants its configuration information in a file called httpd.conf, where the script directory is defined in this fashion:

   Exec            /cgi-bin/                    /usr/local/httpd/cgi-bin

Now you should be ready to begin your first CGI program, no matter what operating system you’re running.

Perl Meets the World Wide Web

You learned in Skill 1 that a Perl print statement writes the text and variables following it to the screen, known among systems folks as the standard output, or stdout. This is a key concept, because in CGI, the Web server in a sense becomes the standard output, or the screen. What really happens is actually more complicated than that, but the main thing for you to understand is that when you print anything from a Perl program through CGI, it will be shipped to the server, which then has to figure out what to do with it.


Previous Table of Contents Next


Products |  Contact Us |  About Us |  Privacy  |  Ad Info  |  Home

Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc.
All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited.