
NETWARE CGI SCRIPTS

CGI stands for Common Gateway Interface, that is a mechanism for 
accessing information other than text documents from the World 
Wide Web.  A CGI program, known as a script, is run by the server 
to generate a document containing the information.  The server then 
sends this information back to the web browser.  Such scripts could 
return such dynamic information as the current time, server status, a 
random witty saying, or the results of a query to some database.

CGI scripts can also receive input from HTML forms.  These forms 
allow the user to enter information for processing by the script.  
HTML forms cover a variety of input mechanisms; including text 
boxes, pull down menus, and radio buttons.  The user input can be 
used in scripts which query databases, collect survey information, 
order products and respond automatically to requests for more 
information.  Scripts such as these greatly increase the flexibility 
and sophistication of your web pages.

DIFFERENCES IN NETWARE CGI SCRIPTS

The current revision of the CGI specification, 1.1, is designed 
primarily for UNIX type operating systems.  As a result, some 
aspects of the specification are difficult to implement under 
NetWare.  The following differences should be noted when writing, 
or porting, CGI scripts.

STDIN/STDOUT

The handling of stdin and stdout under GLACI-HTTPD is the 
biggest deviation from the CGI standard.  Because NetWare cannot 
use I/O streams of one process as stdin/stdout of a spawned process, 
files must be used instead.  The server generates to temporary 
filenames.  It then stores the input, to the script, in one and waits to 
receive the output, from the script, in the other.  The files are then 
deleted.  We are working on a more efficient solution to this 
problem.

Under NetWare 4.0 and later, this is accomplished using the 
standard clib redirection when the process is spawned.  The script 
can read and write from stdin/stdout normally and the file access 
will be done transparently.   

If you are using version 3.11 or 3.12 of NetWare, things are a little 
more complicated.  In this case you must read input and write output 
directly to these files.  The names of the files are passed in as 
commandline arguments.  The input filename is argv[6], while the 
output filename is argv[7].  The easiest way to work with these file  
is to use the following commands

	freopen(argv[6],"r",stdin);
	freopen(argv[7],"w",stdout);

These commands will allow you to access the files through stdin and 
stdout normally through the rest of the program.  Simply removing 
these two lines will leave a script that runs under NetWare 4.0.  If 
you are using Perl, the following lines will do the same thing.

	inFile = $ARGV[6];
	outFile = "> " . $ARGV[7];
	close(STDIN);
	close(STDOUT);
	open(STDIN,$inFle);
	open(STDOUT,$outFile);


ENVIRONMENT VARIABLES

The CGI specification includes several environment variables which 
are set by the server and can be user by the script as needed.  
NetWare does not support environment variables, so a subset of the 
variable list is passed to the script as command line arguments.  The 
following chart lists the variable, its position in the argument list, 
and a description of the variable's purpose.

Variable Name    Argument   Description
---------------  ---------  ---------------------------------------------
SCRIPT_NAME      argv[0]    Name of the cgi script
REQUEST_METHOD   argv[1]    HTTP request method, usually get or post.
SERVER_PROTOCOL  argv[2]    Should be HTTP/1.0
REMOTE_ADDR      argv[3]    Internet address of the client
CONTENT_LENGTH   argv[4]    Number of characters being sent by the client.
QUERY_STRING     argv[5]    The unparsed query string sent to the server 
			    as part of the requested URL.

Any variable which does not have a value will contain the 
string __CGI_NO_VALUE__.  


