The cgi.tcl Home Page


cgi.tcl is the CGI support library for Tcl programmers. The library is very thorough - it supports forms, tables, cookies, file upload, plug-ins, JavaScript, Netscape extensions, etc, etc. 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:

NEW! 9/12/99 - Jeffrey Hobbs' new input routine added. 300% speed improvement if you're using Tcl 8.2 or newer.

NEW! 6/25/98 - instructions for MacOS added.

NEW! 4/1/98 - more new examples (framed or unframed) - vote for a t-shirt!

NEW! 12/10/96 - binary upload support!

Obtaining cgi.tcl

You can get cgi.tcl and the examples from 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:

 uncompress cgi.tcl.tar.Z
 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 README file.

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: (or .Z) (or .Z)

Downloadable examples

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.


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 servers
  • fcgi.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.


    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 the purpose.

    Last edited: Mon May 1 14:26:08 EDT 2006 by Don Libes