Scroll to navigation

cgi(5) Programmer's Manual cgi(5)


cgi - Common Gateway Interface


The Common Gateway Interface is a way to create dynamic web pages. It defines rules for interaction between a program and the web server while the server talks to the client. There are some ways to use it.


Normally the webserver sets several environment variables to give some information to the CGI program so it can determine various stuff.

This reflects the authentification method used to validate a user.
The length of the data in bytes passed to the CGI program through standard input. This is used by the POST method.
The MIME type of the query data, such as "text/html", optional.
This reflects the document root directory of the webserver.
Reflects the version of the Common Gateway Interface that the server is using
A comma separated list of MIME type that the client is willing to accept.
The email address of the user issuing the information request. This is not supported by most browsers.
Reflects the URL from which this CGI program was accessed.
The name, version and libraries of the browser making the request. This information can be used to determine if the browser is capable of graphics and is able to display frames and tables.
This shows extra information that was passed to the CGI program via command line. Normally it's empty or non-existent.
The translated path on the local filesystem.
This variable refers to additional arguments that were appended to the CGI program - normally with the '?' sign.
This refers to the host from which the information request was issued, as IP number.
This refers to the host from which the information request was issued.
The authenticated name of the user.
This refers to the method with which the information request was issued. Normally this is either GET or POST.
The virtual name of the script being executed.
The server's hostname or IP number. This may be used to determine the correct paths or resulting HTML code for CGI programs that are used on the same machine for several servers.
This is the name and version of the information protocol the request came in with. Normally this is "HTTP/1.0" or "HTTP/1.1".
This refers to the TCP/IP port on which the webserver is running.
This reflects the name and revision of the webserver software.


This CGI library is written by Martin Schulze <>. If you have additions or improvements please get in touch with him.


cgiDebug(3), cgiHeader(3), cgiSetType(3), cgiSetHeader(3), cgiGetValue(3), cgiGetVariables(3).

6 April 2008 CGI Library