CGI(5) - Linux man page online | File formats

Common Gateway Interface.

6 April 2008
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. AUTH_TYPE This reflects the authentification method used to validate a user. CONTENT_LENGTH The length of the data in bytes passed to the CGI program through standard input. This is used by the POST method. CONTENT_TYPE The MIME type of the query data, such as "text/html", optional. DOCUMENT_ROOT This reflects the document root directory of the webserver. GATEWAY_INTERFACE Reflects the version of the Common Gateway Interface that the server is using HTTP_ACCEPT A comma separated list of MIME type that the client is willing to accept. HTTP_FROM The email address of the user issuing the information request. This is not sup‐ ported by most browsers. HTTP_REFERER Reflects the URL from which this CGI program was accessed. HTTP_USER_AGENT The name, version and libraries of the browser making the request. This informa‐ tion can be used to determine if the browser is capable of graphics and is able to display frames and tables. PATH_INFO This shows extra information that was passed to the CGI program via command line. Normally it's empty or non-existent. PATH_TRANSLATED The translated path on the local filesystem. QUERY_STRING This variable refers to additional arguments that were appended to the CGI program - normally with the '?' sign. REMOTE_ADDR This refers to the host from which the information request was issued, as IP num‐ ber. REMOTE_HOST This refers to the host from which the information request was issued. REMOTE_USER The authenticated name of the user. REQUEST_METHOD This refers to the method with which the information request was issued. Normally this is either GET or POST. SCRIPT_NAME The virtual name of the script being executed. SERVER_NAME 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. SERVER_PROTOCOL 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". SERVER_PORT This refers to the TCP/IP port on which the webserver is running. SERVER_SOFTWARE 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), cgiGetVari‐ ables(3).
CGI Library 6 April 2008 cgi(5)
This manual Reference Other manuals
cgi(5) referred by cgiInit(3) | urweb(1)
refer to cgiDebug(3) | cgiGetValue(3) | cgiHeader(3) | cgiSetHeader(3) | cgiSetType(3)
Download raw manual
Main page Programmer's Manual (+86) CGI Library (+16) № 5 (+2141)
Go top