What is CGI on the server side

CGI interface and Perl interpreter

The CGI interface (Common Gateway Interface - general switching computer interface) is a way of making programs or scripts available on the web that can be called up from HTML files, and that can generate HTML code themselves and send it to a web browser. In contrast to  JavaScript However, such scripts or programs are not executed in the user's browser after a web page has been transmitted, but rather before the browser receives data from the server. This is why CGI scripts or CGI programs can only be executed if there is HTTP-based communication between the web browser and the web server. CGI is located on the server side.

The data processing also takes place on the server computer. CGI programs can store data on the server computer, for example how often a web page was accessed or what a user wrote in a guest book. A CGI script can also query databases installed on the server computer. When called up accordingly, a CGI program can read out stored data and generate HTML code from it. This "dynamically" generated HTML code is transmitted to the calling web browser of a user and can display individual data there in HTML form, for example the current access count of a web page, the previous entries in a guest book or the results of a database search.

The CGI interface must be supported by the web server software. From the perspective of the tenant of storage space on a web server, the CGI interface is usually available in the form of a specific directory with the name. This directory can be used to store scripts that perform CGI tasks. If you are unsure, ask your provider or webmaster, who will provide you with storage space on the web, whether they can provide you with a CGI interface. In the case of inexpensive or even free homepage brokers, there is usually no CGI interface available.

There are no rules as to which programming language a CGI program is written in. In order for the program to be executable on the server computer, it must either have been compiled as an executable program for the operating system environment of the server computer, or there must be a runtime interpreter on the server that executes the program. For example, if the server is a Linux machine, it runs C programs that have been compiled into an executable file using a Linux C compiler. If the server is a Windows NT computer, CGI scripts can also be EXE files that were created with compilers for C, Pascal, Visual Basic, etc. Most of today's CGI programs are not compiled programs, just scripts that are executed by an interpreter when they are called. The best known and most popular interpreter is the Perl interpreter.

Perl is a programming language that is a mixture of classic programming languages ​​such as C and script languages ​​such as Unix shell script. Perl is extremely powerful, and the Perl interpreter is highly sophisticated. Perl has therefore captured the hearts of programmers in countless areas. Among other things, also in the area of ​​CGI programming. For this reason, CGI programming and Perl are now often mentioned in the same breath and represented as belonging together. It is just important to know that the connection between CGI and Perl is not something natural or necessary. CGI is only a standard for a programming interface that web server software should support, and Perl is a universally applicable script language, which, however, is ideally suited for CGI programming due to its characteristics.


CGI / Perl information

There is no standard for CGI that is comparable to the status of HTML, CSS, or XML. The W3 consortium, which also has a working group that takes care of the HTTP protocol, excludes the CGI interface from the HTTP documents. The CGI interface was introduced with one of the first and most successful web server products of the time, namely the NCSA web server (NCSA = National Center for Supercomputing, an academic institution). The original specification for the NCSA CGI interface is still available on the NCSA website:

 The CGI Specification

There is actually not too much involved - it just has to be supported by the web server. The NCSA server no longer plays a role, the clear leading role among the web server products has meanwhile been taken over by the freely available Apache web server. Of course, this also supports the CGI interface.

Perl as a programming language and the Perl interpreter are license-free and available free of charge. The entry page for all matters relating to Perl is  perl.com.


In the link directory of the online offer from SELFHTML aktuell you will find further relevant and current references, e.g. to original documentation and other sources:

 SELFHTML link directory: CGI / Perl

Within this documentation, CGI and Perl are discussed in Chapter  CGI / Perl treated.

© 2001 [email protected]