![]() | Configuration of the Module MOD_cgi |
The module MOD_cgi provides a Common Gateway Interface (CGI) for external routines, that are not implemented as server loadable modules but executable or scripts (batch programs). The main characteristics of CGI programs and scripts are:
In the server's binary directory, you can find two sample of CGI programming. The cgi_prog.c C sample shows the programming of a CGI in the programming language C, the executable cgi_prog.exe (OS/2, Windows) or cgi_prog (Unix) is stored there, two. The cgi_test.bat (Windows), cgi_test.cmd (OS/2) or cgi_test.sh (Unix) file shows a sample CGI written as batch or shell script. It's output can be displayed:
Note:The CGI program or script has to provide the WWW server with these kinds of output lines:
The response code is an optional one line information. It has to be the first line in output and must start with the letters 'HTTP/'. It contains HTTP version, return code and return message. If the line is missing, a default answer is created:
HTTP/1.0 200 OK
The next lines up to a blank line are treaten as header lines. The CGI should create at least a line 'Content-type: xxx', where xxx is the valid content type of the following page. The blank line is treaten as divider. All following lines up to the end of the output are data lines. A sample output could be like this:
HTTP/1.0 200 OK Content-type: text/html Expires: Mon, August 10, 1998 12:00:00 <html> <title>Sample CGI output page</title> </html><body color="white"> <h1>Sample CGI output page</h1> <p>This is a stupid little test.</p> </body> </html> |
... is not necessary. You only have to set the translation path in the Access Path menue of the administration section (plus set the handling mechanism to the module MOD_cgi). Under Unix the OS automatically associates the right command line processor (Perl interpreter, sh, etc.) to the script or executes directly. Under OS/2 direct execution of binaries, batch or Rexx scripts is possible, under windows only binaries and batch scripts are executable. If you want to run Perl scripts under OS/2 or windows, you have to write a wrapper script (batch script calling the perl interpreter with the perl script name as parameter).
| ©. 1998-2000 by Dirk Ohme |