CGI PROGRAM


Meaning of CGI PROGRAM in English

< World-Wide Web > (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

Untitled Document 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.

(2000-06-23)

FOLDOC computer English dictionary.      Английский словарь по компьютерам FOLDOC.