Word:
Browse
CFML
CFO
cforth
cfortran.h
CFP
CFP92
CFS
CfV
cg
CG-VDI
CGA
CGARI
CGDC
CGGL
CGI
CGI Joe
-- CGI program --
CGI script
cgi-bin
CGM
CGMS
CGOL
cgram
CGRM
cgs
cgs system
CGVDI
Ch
ch'i
Ch'ing
Ch'ing dynasty
Cha
cha-cha

CGI program

Advertisement
(World-Wide Web)CGI program - (Often "CGI script") A program running on a web server to produce dynamic content, usually an HTML web page, in response to a user's request.

The Common Gateway Interface specification defines the interface between the web server and such programs. The program can access any data that a normal application program can, however the facilities available to CGI programs are usually limited for security.

Although CGI programs can be compiled programs, they are more often written in a (semi) interpreted language such as Perl, or as Unix shell scripts, hence the name "CGI script".

Here is a trivial CGI script written in Perl. (It requires the "CGI" module available from CPAN).

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

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

When run it produces an HTTP header and then a simple HTML page containing the IP address or hostname of the machine that generated the initial request. If run from a command prompt it outputs:

Content-Type: text/html

<a href=Untitled>Untitled</a> <a href=Document>Document</a>

CGI Test

Your IP address is: localhost

The CGI program might be saved as the file "test.cgi" (or test.pl) in the appropriate directory on a web server, e.g. "/home/httpd/cgi-bin/".

A user could then type the appropriate URL, e.g. http://www.acme.com/cgi-bin/test.cgi, into their web browser to get the program to run and a custom page produced for them.

Early web servers required all CGI programs to be installed in one directory called cgi-bin but it is much better to keep them with the HTML files to which they relate unless they are truly global to the site. All modern web servers make this easy to do.

About this site and copyright information - Online Dictionary Home