Troubleshooters.Com Presents

July 1999 Troubleshooting Professional Magazine: Troubleshooting CGI

Copyright (C) 1999 by Steve Litt. All rights reserved. Materials from guest authors copyrighted by them and licensed for perpetual use to Troubleshooting Professional Magazine. All rights reserved to the copyright holder, except for items specifically marked otherwise (certain free software source code, GNU/GPL, etc.). All material herein provided "As-Is". User assumes all risk and responsibility for any outcome.

<--Editors Desk   |  Contents   |   Troubleshooting Review-->

CGI Review

By Steve Litt
You can skip this article if you're familiar with its concepts. CGI stands for Common Gateway Interface, a method of communication between web browsers and web servers. It's trivially simple, consisting of an ordinary computer program,  with specific but simple standards for information input and output, normally run on the computer hosting the web pages. When used thusly, the computer program is called a CGI program.

The CGI program sends info to to the browser simply by outputting that info to stdout (the same device that normally writes to the computer monitor).

The CGI program receives info from the browser in one of two ways, called GET and POST. In the GET method, the browser's information is available to the CGI program through the QUERY_STRING environment variable. In the POST method, the browser's information is available to the CGI program through the CGI program's stdin, with the CONTENT_LENGTH environment variable containing the number of bytes transmitted to the server's stdin. Note that the CGI program can deduce whether the communication is GET or POST by reading the REQUEST_METHOD environment variable. Since POST is by far the more common, the remainder of this Troubleshooting Professional will concentrate on the POST method.

That's it. That's CGI. Did you notice nothing in the above description restricted CGI to a specific computer language (like Perl)? While Perl is one of the most productive CGI languages, CGI can be written in any language capable of reading environment vars and stdin and writing stdout. Perl, Python, C, C++ and shellscript are commonly used, although obviously Perl is the most common.

In a later article, this issue of Troubleshooting Professional offers a series of CGI scripts, written in shellscript and Perl, that can be used as testpoint access tools.

Steve Litt can be reached at Steve Litt's email address.