cgi.tcl is the CGI support library for Tcl programmers. The
library is very thorough - it supports forms, tables, cookies,
It also provides very convenient support for debugging and
handling CGI errors.
cgi.tcl can also be used for generating static html (such as
this page). This enables you to get programming features into HTML,
such as variables, if/then/else, file I/O, etc. For example, HTML
lacks variables so if you repeatedly use a link on a page and one day
the link changes, you've got to update every use of the link,
possibly on hundreds of pages. By storing the link in a Tcl
variable, you can just change the one place where the variable is
defined. This makes maintenance much easier. This is just
a tiny example of the benefits cgi.tcl provides.
cgi.tcl runs on any system (UNIX, Win, or Mac) which supports
all versions of Tcl from 7.4 to 8.2. The current version of cgi.tcl is 1.10.0.
Frequently asked questions are answered in the FAQ.
A list of changes, bug fixes, enhancements is available in the
History file. Noteworthy recent developments:
You can get cgi.tcl and the examples from expect.nist.gov as cgi.tcl.tar.Z or cgi.tcl.tar.gz.
The gz file is preferrable simply because it is quicker to download.
However, if you have no idea what to do with a gz file once you've got
it, just transfer the Z version of the distribution.
If you are on UNIX, at the command line, type:
tar -xvf cgi.tcl.tar
If you are on Win95, Win98, or NT,
download the distribution into a
directory that is in the lib path of Tcl such as c:\\tcl\\lib\\tcl8.0
(note double back slashes). Unpack the distribution using
WinZip95 or some equivalent program.
This will create a directory containing the cgi.tcl distribution.
Change to that directory and read the README file.
If you are on MacOS, unpack the distribution and read the
Note 1: cgi.tcl requires Tcl. If you don't already have Tcl, you
can get it as tcl.tar.Z
or ...gz. To install Tcl,
just mimic the instructions as for cgi.tcl.
Note 2: If you want to download cgi.tcl (or Tcl) without using a
web browser, you will need to know the ftp-style URLs. Yes, they're
a lot longer and clumsier than the web-style URLs. The ftp URLs are:
ftp://ftp.nist.gov/mel/div826/subject/expect/cgi.tcl/cgi.tcl.tar.gz (or .Z)
ftp://ftp.nist.gov/mel/div826/subject/expect/cgi.tcl/tcl.tar.gz (or .Z)
You can try out the examples (framed or unframed) without
downloading the distribution. On each example page, there is a
link to view the source.
If you would like to show off what you've written with cgi.tcl,
give me an html-formatted blurb and I'll add it to a page
of real applications or puts it in the contributed scripts directory.
- Libes, D., Writing CGI Scripts in Tcl (ps), Proceedings of the
Fourth Annual Tcl/Tk Workshop '96, Monterey, CA, July 10-13, 1996. -
This paper provides a high-level overview of the ideas behind cgi.tcl
with many examples. I recommend you read this paper before using
- The draft reference manual contains the precise
definition of the cgi.tcl library. This document can also be
found in doc/ref.txt inside the cgi.tcl distribution.
- The README from the cgi.tcl distribution has
lots of valuable information
that has yet to be incorporated into this home page. It includes a
description of the software distribution, where and how to send bug
reports, how to get support, and some other background information.
- Examples can be found on the web (framed or unframed),
or in the example directory of the
distribution. There are examples demonstrating cookies, error
handling, running /bin/passwd, file upload, visitor counting, etc.
- cgi.tcl was written around the end of '95
and then rewritten after writing the Tcl/Tk Workshop paper on it
in early '96. Except for minor bug fixes and some new features, it's
been quite stable since then. A list of changes, bug fixes,
enhancements is available in the History file. It also
provides an easy way of finding out if you need to
Other closely-related work or papers
[The following statement is required per NIST policy] By
selecting these links, you will be leaving NIST webspace. We have
provided these links to other web sites because they may have
information that would be of interest to you. No inferences should be
drawn on account of other sites being referenced, or not, from this
page. There may be other web sites that are more appropriate for your
purpose. NIST does not necessarily endorse the views expressed, or
concur with the facts presented on these sites. Further, NIST does not
endorse any commercial products that may be mentioned on these sites.
htmlgen and xmlgen - These packages take the cgi.tcl idea of a-Tcl-command-for-every-tag and provide a clean framework for creating any XML in Tcl. htmlgen is the same thing but with definitions for HTML.List of low-cost ISPs that allow Tcl-based CGI scripts on their serversfcgi.tcl is a Tcl interface for the FastCGI protocol.
FastCGI is a web server-neutral API for server side programming.
You can think of FastCGI as persistent CGI; FastCGI programs start
up once and serve CGI requests without having to restart for each
new request. Typical CGI programs can be converted to FastCGI
programs with very little work. Fcgi.tcl comes in two flavors: a 100%
Tcl flavor, and a C extension flavor. Both flavors offer the same
programming interface for Tcl CGI programs. Fcgi.tcl is designed to
work with cgi.tcl. Fcgi.tcl was written by Tom Poindexter.SSLtcl extends the socket command
with SSL, for performing financial and other high-security
transactions. SSLtcl is a wrapper around SSLeay.Web Authoring Toolkit is a Tcl/Tk-based
HTML editor/browser written by Brent Welch and Steve Uhler,
Sun Microsystems.Plume is a Tcl-based WWW browser
written by Steve Ball, Australian National University.
Among its interesting features is the ability to execute
Tcl applets and the ability to dynamically extend the
browser at runtime.Tk plugin enables
execution of Tcl and Tk in Netscape Navigator and Microsoft
Internet Explorer. Written by Jacob Levy, Sun Microsystems.tcl2html formats Tcl
code for presentation in HTML. Written by Jeffrey Hobbs,
University of Oregon. See
tcl2html run on itself.FAQ builder is a
Tcl-based package for building and easily maintaining FAQs.
For example, the Expect FAQ is a real
FAQ maintained this way.There are also several http servers that can evalute
Tcl commands directly using an augmented HTML.
- The Red Olive toolkit provides is a higher-level library sits on top of cgi.tcl and provides very elegant pages with even simpler code.
- mod_dtcl embeds Tcl into the Apache httpd. mod_dtcl was written by David Welton, Debian.
- NewWebScript embeds Tcl into the Apache httpd. NewWebScript was written by Karl Lehenbauer, Neosoft.
- Audience1 by Adam Sah, Kevin Brown, and Eric Brewer, Inktomi Corporation.
- Tcl Web Server is a web server written entirely in Tcl. The Tcl Web Server was written by Brent Welch and Steve Uhler, Sun Microsystems.
- scwsd is a very small web server - only 200 lines of Tcl! Handy as a quick and easy way to set up a web site (static data only) - no config files! Written by Larry Smith.
- Castle is another Tcl-based web server with support for Tcl as a macro markup-language. Written by Larry Smith.
is another web server written entirely in Tcl. Written by
- AOLServer by AOL (nee Navisoft).
(Philip Greenspun's commentary).
- ACS (Arsdigita Community System) - support for aolserver.
- Velocity Engine embeds the Tcl interpreter into an http server.
- webshell is a rapid development environment for web applications; includes an Apache module.
- proxyTk uses Tcl and a subset of Tk on the server - and a java applet to render the tk commands on the client side.
Go back to cgi.tcl homepage.
Names of companies and products, and links to commercial pages are
provided in order to adequately specify procedures and equipment used.
In no case does such identification imply recommendation or
endorsement by the National Institute of Standards and Technology, nor
does it imply that the products are necessarily the best available for
Last edited: Mon May 1 14:26:08 EDT 2006 by Don Libes