Common Gateway Interface

(redirected from .cgi)

common gateway interface

[‚käm·ən ‚gāt‚wā ′in·tər‚fās]
(computer science)
A protocol that allows the secure data transfer to and from a server and a network user by means of a program which resides on the server and handles the transaction. For example, if an intranet user sent a request with a Web browser for database information, a CGI program would execute on the server, retrieve the information from the database, format it in HTML, and send it back to the user. Abbreviated CGI.

Common Gateway Interface

(World-Wide Web)




#!/usr/bin/perl use CGI qw(:standard);

print header, start_html, h1("CGI Test"), "Your IP address is: ", remote_host(), end_html;



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" ""> <html xmlns="" lang="en-US" xml:lang="en-US"> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> </head> <body> <h1>CGI Test</h1>Your IP address is: localhost </body> </html>





Latest version: CGI/1.1.

CGI script

(Common Gateway Interface script) A relatively compact program written in a language such as Perl, Tcl, C or C++ that processes data on a Web server. It is commonly used to process a query from the user that was entered on an HTML page (Web page) and returned as an HTML page, in which case the CGI script functions as the glue between the query and the database. For example, it would pull the search data out of the GET request in the HTML form, look it up in the database management system (DBMS) and format the results as an HTML page that is sent back to the user.

CGI scripts were the initial mechanism used to make websites interact with databases and other applications. However, as the Web evolved, other server-side processing methods were developed that are more efficient than CGI, such as Active Server Pages (ASPs), JavaServer Pages (JSPs) and servlets. See ASP, JSP, servlet and FastCGI.

Web Server Evolution
Starting at the top and moving down, this illustration shows Web and application server processing as it evolved initially using only CGI scripts and later using Java components. The separation of logic is portrayed here, and the Web server (HTTP server) and application server may reside in the same or different computers.