You want to test that you have CGI enabled correctly. Alternatively, you are receiving an error message when you try to run your CGI script and you want to ensure the problem doesn't lie in the web server before you try to find a problem in the script.
#! /usr/bin/perl print "Content-type: text/plain\r\n\r\n"; print "It's working.\n";
And then, if things are still not working, look in the error log.
Because Perl is likely to be installed on any Unixish system, this CGI program should be a pretty safe way to test that CGI is configured correctly. In the event that you do not have Perl installed, an equivalent shell program may be substituted:
#! /bin/sh echo Content-type: text/plain echo echo It\'s working.
And, if you are running Apache on Windows, so that neither of the above options works for you, you could also try this with a batch file:
echo off echo Content-type: text/plain echo. echo It's working.
Make sure that you copy the program code exactly, with all the right punctuation, slashes, etc., so that you don't introduce additional complexity by having to troubleshoot the program itself.
In either case, once the program is working, you should see something like the following screen capture (see Figure 8-1).
Figure 8-1. Your CGI program worked
The idea here is to start with the simplest possible CGI program to ensure that ...