Drag and Drop CGI | 6 | WebReference

Drag and Drop CGI | 6

Step 2: Installation

If you've installed scripts from earlier chapters in this book, you can probably install ICE with your eyes closed. For those who skipped the earlier chapters, we recommend that you read Chapter 3, ``The Nonprogrammer's Toolbox,'' for the specifics.

Start your FTP client and upload the ice-idx.pl and ice-form.pl files to the cgi-bin directory (also called cgi or htbin). Be sure to use ASCII mode when transferring the Perl scripts.

Once the script files are safely aboard your Web server, you need to change the file permissions to tell the system that they are executable files.

Remember: You may need to rename your ice-form script to have a .cgi extension depending on the requirements of your Web server.

That's all there is to installing the scripts on your server. Creating the actual Web site index is the final step in the ICE installation. If you've edited everything correctly in the script files, entering the following command from your Telnet client will generate the index of your site:


The script doesn't produce any output to the screen, but you can check for the index file at the location you specified in the script's configuration block. If you told the script to put your file somewhere other than in the cgi-bin/ directory, list the contents of that directory using ls. You don't actually have to change to the directory to list it. Just give the complete path to the directory you want to list and ls will oblige. The command:

ls /home/users/joeuser/public_html/cgi-bin

will give you a list of the files in that directory from anywhere on the server (note the leading /, which makes the path absolute from the file system root). On Windows, the syntax is

dir d:\users\joeuser\htdocs\cgi-bin\

Once you've verified that the index file exists, you can conduct a little test of the search function by running the ice-form.cgi script by hand. Enter the following -command:


You should get a short message about running in test mode, and the script will do a search on the word ``the.'' The output of the search will be a bunch of HTML that will scroll off the screen before you can read it. If you get this output, your script is working. You can play around with the test function by adding a less common word after the name of the script on the command line, such as ``kumquat'':

ice-form.cgi kumquat

The script will produce HTML that lists all the pages with the word ``kumquat'' (or words containing ``kumquat'' such as ``kumquats'' or ``kumquatish'') in them. Once you've finished amusing yourself with the form script, you can test it with the browser. Using your browser's Open Location function, enter your home page URL followed by the cgi directory and the script name:




The browser should respond with a search form like that shown in Figure 12.2. Enter a search word and submit the form. You should get a listing, resembling Figure 12.3, of all your pages containing the word you've chosen. Check the file-to-URL mapping by clicking one of the links. The page should load correctly on your browser.

There are only a few things that can go wrong with the scripts. One is that if the @SEARCHDIRS variable is set incorrectly, you won't index some or all of the direc-tories with HTML files. If you don't get any matches to your search with words you know are in your pages, you will need to recheck the configuration of the indexing script. Just switch to your text editor and edit the script file. Save your changes and re-upload the script over the current one on the server. The file permissions won't need to be set again. Repeat this edit-upload-test cycle until things are working correctly. If you are correcting the index script, you'll need to generate a new index by executing the script on the Telnet client each time you make a change.

A much more common problem is that the ice-form.cgi script has correctly generated the index, but it returns incorrect links. This usually indicates a problem with the %urltopath variable in the ice-form.cgi file. Observe the links the script is generating and modify %urltopath to produce the correct output. After the basic search is working, try limiting the search to a specific directory if you listed more than one in the @directories variable. (Remember, these are URL fragments within the parentheses, not file paths.) Observe the search script output and make adjustments until it is producing valid links.

Congratulations, your Web site search engine is now installed and working!

Comments are welcome

Copyright © 1997 Addison-Wesley Pub Co. and
Created: Oct. 24, 1997
Revised: Oct. 27, 1997

URL: http://webreference.com/dev/dndcgi/install.html