CGI Development and chtml

For the most part, developing CGI scripts and binaries on is the same as on other servers. Many of the differences are outlined in CGI Scripts on This example describes the implementation (as of March, 2000) of cgitest.cgi, which is written in Perl.

Template file

This script uses a template file which is processed by chtml. Markers are placed in the file which tell the script where to substitute values. You can view the source or an annotated description of the source.

Perl script

In addition to using chtml, this script uses for its interface with the server and to create HTML. In addition, it uses the Perl strict module to enforce more secure coding. You can view the source or an annotated description of the script.

Using the script

This script can be directly called to examine the defined environment variables available to your script. You can also make it the action of a web form to examine form parameters. For example, the following HTML:

<form method="post" action="cgitest.cgi">
  Text field: <input type="text" name="textfield"><br>
  <input type="checkbox" name="checkbox" value="checkbox1"> checkbox1 
  <input type="checkbox" name="checkbox2" value="checkbox2"> checkbox2<br>
  Radio Buttons: 
  <input type="radio" name="radiobutton" value="radiobutton1"> radiobutton1 
  <input type="radio" name="radiobutton" value="radiobutton2"> radiobutton2<br>
  Hidden field: 
  <input type="hidden" name="hiddenField" value="hidden">
  <i>hidden field not visible</i><br>
  Submit buttons: 
  <input type="submit" name="Submit" value="Submit">
  <input type="submit" name="Submit2" value="Submit2">

generates the following form:

Text field:
Checkboxes: checkbox1 checkbox2
Radio Buttons: radiobutton1 radiobutton2
Hidden field: hidden field not visible
Submit buttons:

You can fill in various parameters of the form to see how the script responds.