Webbworks CGI Library


CGI (Common Gateway Interface) scripts allow you to add interactive features to your Web pages. Users have permission to compose and use CGI scripts from their personal WebPage directories, but most common tasks can be achieved using one of the prepared scripts in our Library. If you wish to implement your own scripts, you must make two changes to your file before it can be used:
  • All scripts must end with ".cgi".
    (Note that if you intend to use an interpreted script, such as Perl or Shell scripts, you will need to retain the respective suffix (.pl for Perl, .sh for Shell) in addition to the .cgi suffix. So if you have a CGI script written in Perl called "mycgi", you would need to name the file "mycgi.pl.cgi" for it to execute properly; otherwise, you will probably get a server error when you try to access it from a Web page.)

  • All scripts must be both world readable and executable.
    e.g. % chmod 755 my-cgi.cgi

For more information on preparing CGI scripts, you may wish to consult the documentation for our Apache server, as well as the specifications for CGI 1.1. More references and examples of CGI programming are listed on the Web Resources page.

Script Library

  • Form Processor: formmail

    Copyright 1996 Matt Wright
    Created on 6/9/95 Last Modified: 2/5/96
    Version 1.5

    Formmail accomplishes one of the most commonly requested CGI tasks - it accepts data submitted from a form, decodes and formats it according to your specifications, and mails the results to you. To use Formmail, you need to call it from your FORM tag:

    <FORM METHOD=POST ACTION="/scripts/cgi-bin/formmail.pl">

    In addition, you will need to add at least one hidden FORM element to specify where to email the results:

    <INPUT TYPE=hidden NAME="recipient" VALUE="username@webbworks.com">

    Other formatting options for the email output include:

    <INPUT TYPE=text NAME="email" VALUE="sender@hostname" WIDTH=30> (for the From field)
    <INPUT TYPE=text NAME="realname" VALUE="Real Name" WIDTH=30> (to add a 'real name' after the From address)
    <INPUT TYPE=hidden NAME="subject" VALUE="Reason for Form"> (for the Subject field; this will often be hidden)

    More configuration options, such as required fields and output sorting, are available in the latest revision; check the documentation for details.

  • Imagemaps: imagemap support is now handled natively by our server. Simply create a NCSA-compatible map file, upload it with your site, and anchor the imagemap graphic with a reference to the file. For example, if you have a imagemap graphic called "map.gif" and a NCSA map file called "where.map" both in the same directory, the tag would look like:

    <A HREF="where.map"><IMG SRC="map.gif" ISMAP></A>

  • Page Counter: Count 2.3

    To add a counter to your page, consult our Learn to Count! primer.

  • URL Redirection: PERL redirect script

    by Carlos A. Pero; last updated 10/22/95

    This redirect script will accept input from a FORM, either via METHOD GET or POST, and send a 300-level HTTP status code to redirect the browser to a new URL.

    There are two ways to use a FORM in conjunction with this script:

    1. A list of URLs with a submit button

    <FORM METHOD="POST" ACTION="/scripts/cgi-bin/redirect.pl">
    <SELECT NAME="url">
    <OPTION VALUE="http://www.ncsa.uiuc.edu/">NCSA
    <OPTION VALUE="http://hoohoo.ncsa.uiuc.edu/">HTTPd
    <OPTION VALUE="http://www.uiuc.edu/">U of I
    </SELECT>
    <INPUT TYPE="submit" VALUE="Go to URL">
    </FORM>

    produces...

    In this case, the script will find the input called "url" and redirect the browser to this location.

    2. Multiple submit buttons

    <FORM METHOD="POST" ACTION="/scripts/cgi-bin/redirect.pl">
    <INPUT TYPE="submit" NAME="http://www.ncsa.uiuc.edu/" VALUE="NCSA">
    <INPUT TYPE="submit" NAME="http://hoohoo.ncsa.uiuc.edu/" VALUE="HTTPd">
    <INPUT TYPE="submit" NAME="http://www.ncsa.uiuc.edu/" VALUE="U of I">
    </FORM>

    produces...

    In this case, the script will find an input NAME that looks like a URL, and redirect the browser to this location.

    Either method should work fine, just don't use both within the same FORM.

Copyright © 1996 - 2004 WEBBWORKS, INC.  All rights reserved. 
WEBBWORKS.COM™ and the WEBBWORKS.COM™ Logo
are Trademarks of WEBBWORKS, INC. Company
(509) 545-9706 - 4006 Desert Drive, Pasco, WA.  99301-9405

Copyright 1996 - 2004 Webbworks Inc., All Rights Reserved