University of Virginia Department of
    Computer Science

Common Gateway Interface

Introduction

Here's a blurb from the NCSA people explaining what CGI is:
The Common Gateway Interface (CGI) is a standard for interfacing external applications with information servers, such as HTTP or Web servers. A plain HTML document that the Web daemon retrieves is static, which means it exists in a constant state: a text file that doesn't change. A CGI program, on the other hand, is executed in real-time, so that it can output dynamic information.
The best way to get introduced to CGI is to read over the NCSA page.

CGI at UVA

We have the CGIwrap package installed, it allows users without special privileges to have the web server call CGI scripts on their behalf. It also makes CGI scripts more secure.

See the cgiwrap manpage for detailed setup and usage information. It really is useful. Paco has a series of talks on Advanced Web Techniques. CGI is one of those topics.

The CGIwrap ftp site is ftp://ftp.cc.umr.edu/pub/cgi/cgiwrap/.

Example

This link: uptime shows load info for the web server machine. The URL in the link is: http://www.cs.virginia.edu/cgi-bin/cgiwrap?user=helpnet&script=uptime

The CGI script is the following simple shell script (located in ~helpnet/public_html/cgi-bin), whose standard output is read by the web server and sent to the browser. Note that it should output HTML rather than plain text.

'#!/bin/sh
UPTIME=/usr/ucb/uptime
echo Content-type: text/plain
echo
if [ -x $UPTIME ];  then
	$UPTIME
else 
	echo Cannot find uptime command on this system.
fi

Also See



HelpNet
HelpNet was created by the 1995 incoming graduate class. It is only occasionally updated.
Department of Computer Science
School of Engineering, University of Virginia
151 Engineer's Way, P.O. Box 400740
Charlottesville, Virginia 22904-4740

(434) 982-2200  Fax: (434) 982-2214
Web Comments: webteam@cs.virginia.edu
Admissions Inquiries: inquiry@cs.virginia.edu
Site directory, Other addresses
Server statistics
© Created by the CS Web Team