Table of Contents
This document is also available in the following languages: Italian, Russian
Document revision: $Revision: 1.52 $, last modified $Date: 2005/03/12 14:26:20 $ by $Author: davidw $.
Apache Rivet is a system for creating dynamic web content via a programming language integrated with Apache Web Server. It is designed to be fast, powerful and extensible, consume few system resources, be easy to learn, and to provide the user with a platform that can also be used for other programming tasks outside the web (GUI's, system administration tasks, text processing, database manipulation, XML, and so on). In order to meet these goals, we have chosen the Tcl programming language to combine with the Apache Web Server.
In this manual, we aim to help get you started, and then writing productive code as quickly as possible, as well as giving you ideas on how to best take advantage of Rivet's architecture to create different styles of web site.
This documentation is a work in progress, and, like everything else about Apache Rivet, it is Free Software. If you see something that needs improving, and have ideas or suggestions, don't hesitate to let us know. If you want to contribute directly, better yet!
Check Dependencies
To install Rivet, you will need Tcl 8.2 or greater and Apache 1.3.xx. It is known to run on Linux, FreeBSD, OpenBSD, and Solaris and HPUX. Windows NT is also possible - please see the directions in the distribution.
Get Rivet
Download the sources at http://tcl.apache.org/rivet/download. Currently the only way to obtain Rivet. In the future, we hope to have a FreeBSD port, Debian package, RPM's, and windows binaries.
Install Tcl
If you don't have Tcl already, you need it! If you already have it, you should just be able to use your system Tcl as long as it is recent. You can tell Rivet where Tcl is via the -with-tclconfig option to configure.tcl (see below).
Get and Install Apache Sources
Rivet needs some Apache include (.h) files in order to build. The easiest way to get them is to download the source code of the Apache web server, although some systems (Debian GNU/Linux for example) make it possible to install only the headers and other development files. If you intend to build Rivet statically (compiled into the Apache web server instead of loaded dynamically), you definitely need the sources. We recommend that you build Rivet as a loadable shared library, for maximum flexibility, meaning that you also build Apache to be able to load modules. Other than that, the default Apache install is fine. We will tell Rivet where it is located via the -with-apxs option to configure.tcl (see below).
The source code for the Apache web server may be found by following the links here: http://httpd.apache.org/.
Uncompress Sources
We will assume that you have Apache installed at this point. You must uncompress the Rivet sources in the directory where you wish to compile them.
gunzip tcl-rivet-X.X.X.tar.gz tar -xvf tcl-rivet-X.X.X.tar.gz
Building Rivet
On Linux or Unix systems, Rivet uses the standard ./configure ; make ; make install technique.
Run ./configure.tcl
This is similar to the configure script included with many systems. It's written in Tcl though, for increased speed and clarity. It takes several arguments:
cd src/ ./configure.tcl Configuring .........done.
Run make.tcl
At this point, you are ready to run the build system:
./make.tcl option
where option can be either shared or static.
Install
Now, you are ready to run the ./make.tcl install command to install the resulting files. This should copy the shared object (like mod_rivet.so, if one was successfully created, into Apache's libexec directory, as well as install some support scripts and various code.
Apache Configuration Files
Rivet is relatively easy to configure - we start off by adding the module itself:
LoadModule rivet_module /usr/lib/apache/1.3/mod_rivet.so
This tells Apache to load the Rivet shared object, wherever it happens to reside on your file system. Now we have to tell Apache what kind of files are "Rivet" files and how to process them:
AddType application/x-httpd-rivet .rvt AddType application/x-rivet-tcl .tcl
These tell Apache to process files with the .rvt and .tcl extensions as Rivet files.
For other directives that Rivet provides for Apache configuration, please see the section called “Rivet Apache Directives”.
These directives are used within the Apache httpd server configuration files to modify Apache Rivet's behavior. Their precedence is as follows: RivetDirConf, RivetUserConf, RivetServerConf, meaning that DirConf will override UserConf, which will in turn override ServerConf.
RivetServerConf GlobalInitScript "source /var/www/foobar.tcl"
![]() | Note |
|---|---|
| This code is evaluated at the global level, not inside the request namespace where pages are evaluated. | |
The var command retrieves information about GET or POST variables sent to the script via client request. It treats both GET and POST variables the same, regardless of their origin. Note that there are two additional forms of var: var_qs and var_post. These two restrict the retrieval of information to parameters arriving via the querystring (?foo=bar&bee=bop) or POSTing, respectively.
The upload command is for file upload manipulation. See the relevant Apache Directives to further configure the behavior of this Rivet feature.
Load the headers that come from a client request into the provided array name, or use headers if no name is provided.
Load the array of cookie variables into the specified array name. Uses array cookies by default.
Load the array of environment variables into the specified array name. Uses array ::request::env by default.
As Rivet pages are run in the ::request namespace, it isn't necessary to qualify the array name for most uses - it's ok to access it as env.
If it is only necessary to load one environmental variable, this command may be used to avoid the overhead of loading and storing the entire array.
Include a file without parsing it for processing tags <? and ?>. This is the best way to include an HTML file or any other static content.
Like the Tcl source command, but also parses for Rivet <? and ?> processing tags. Using this command, you can use one .rvt file from another.
The headers command is for setting and parsing HTTP headers.
Create a self referencing URL from a filename. For example:
makeurl /tclp.gif
returns http://[hostname]:[port]/tclp.gif. where hostname and port are the hostname and port of the server in question.
cookie gets or sets a cookie. When you get a cookie, the command returns the value of the cookie, or an empty string if no cookie exists.
Convert an integer-seconds-since-1970 click value to RFC850 format, with the additional requirement that it be GMT only.
Print text with the added ability to pass HTML tags following the string. Example:
html "Test" b i
produces: <b><i>Test</i></b>
Increment a variable varname by num. If the variable doesn't exist, create it instead of returning an error.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.
Scans through each character in the specified string looking for any special (with respect to SGML, and hence HTML) characters from the specified string, and returns the result. For example, the right angle bracket is escaped to the corrected ampersand gt symbol.
Scans through each character in the specified string looking for any shell metacharacters, such as asterisk, less than and greater than, parens, square brackets, curly brackets, angle brackets, dollar signs, backslashes, semicolons, ampersands, vertical bars, etc.
For each metacharacter found, it is quoted in the result by prepending it with a backslash, returning the result.
Scans through each character in the specified string looking for escaped character sequences (characters containing a percent sign and two hexadecimal characters, unescaping them back to their original character values, as needed, also mapping plus signs to spaces, and returning the result.
This is useful for unquoting strings that have been quoted to be part of a URL.
Some examples of Rivet usage follow. Some prior Tcl knowledge is assumed. If you don't know much Tcl, don't worry, it's easy, and there are some good resources available on the web that will get you up to speed quickly. Go to the web sites section and have a look.
Example 1. Hello World
As with any tool, it's always nice to see something work, so let's create a small "Hello World" page.
Assuming you have Apache configured correctly, create a file called hello.rvt where Apache can find it, with the following content:
<? puts "Hello World" ?>
If you then access it with your browser, you should see a blank page with the text "Hello World" (without the quotes) on it.
Example 2. Generate a Table
In another simple example, we dynamically generate a table:
<? puts "<table>\n"
for {set i 1} { $i <= 8 } {incr i} {
puts "<tr>\n"
for {set j 1} {$j <= 8} {incr j} {
set num [ expr $i * $j * 4 - 1]
puts [ format "<td bgcolor=\"%02x%02x%02x\" > $num $num $num </td>\n" \
$num $num $num ]
}
puts "</tr>\n"
}
puts "</table>\n" ?>
If you read the code, you can see that this is pure Tcl. We could take the same code, run it outside of Rivet, and it would generate the same HTML!
The result should look something like this:

Example 3. Variable Access
Here, we demonstrate how to access variables set by GET or POST operations.
Given an HTML form like the following:
<form action="vars.rvt">
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><input name="title"></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><input name="salary"></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><input name="boss"></td></tr>
<tr>
<td><b>Skills:</b></td>
<td>
<select name="skills" multiple="multiple">
<option>c</option>
<option>java</option>
<option>Tcl</option>
<option>Perl</option>
</select>
</td>
</tr>
<tr>
<td><input type="submit"></td>
</tr>
</tbody>
</table>
</form>
We can use this Rivet script to get the variable values:
<?
set errlist {}
if { [var exists title] } {
set title [var get title]
} else {
set errlist "You need to enter a title"
}
if { [var exists salary] } {
set salary [var get salary]
if { ! [string is digit $salary] } {
lappend errlist "Salary must be a number"
}
} else {
lappend errlist "You need to enter a salary"
}
if { [var exists boss] } {
set boss [var get boss]
} else {
set boss "Mr. Burns"
}
if { [var exists skills] } {
set skills [var list skills]
} else {
lappend errlist "You need to enter some skills"
}
if { [llength $errlist] != 0 } {
foreach err $errlist {
puts "<b> $err </b>"
}
} else {
puts "Thanks for the information!"
?>
<table>
<tbody>
<tr>
<td><b>Title:</b></td>
<td><? puts $title ?></td>
</tr>
<tr>
<td><b>Boss:</b></td>
<td><? puts $boss ?></td>
</tr>
<tr>
<td><b>Salary:</b></td>
<td><? puts $salary ?></td>
</tr>
<tr>
<td><b>Skills:</b></td>
<td><? puts $skills ?></td>
</tr>
</tbody>
</table>
<?
}
?>
The first statement checks to make sure that the boss variable has been passed to the script, and then does something with that information. If it's not present, an error is added to the list of errors.
In the second block of code, the variable salary is fetched, with one more error check - because it's a number, it needs to be composed of digits.
The boss variable isn't required to have been sent - we set it to "Mr. Burns" if it isn't among the information we received.
The last bit of variable handing code is a bit trickier. Because skills is a listbox, and can potentially have multiple values, we opt to receive them as a list, so that at some point, we could iterate over them.
The script then checks to make sure that errlist is empty and outputting a thankyou message. If errlist is not empty, the list of errors it contains is printed.
Example 4. File Upload
The following HTML in one file, say, upload.html
<form action="foo.rvt" enctype="multipart/form-data" method="post"> <input type="file" name="MyUpload"></input> <input type="submit" value="Send File"></input> </form>
Can be used with the following Tcl code, in a second file (upload.rvt for instance) in order to create a file upload form.
<? upload save MyUpload /tmp/uploadfiles/file1 puts "Saved file [upload filename MyUpload] \ ([upload size MyUpload] bytes) to server" ?>
In addition to the core Apache module, Rivet provides a number of Tcl packages that include potentially useful code.
An html version of the standard Tcl parray command. Displays the entire contents of an array in a sorted, nicely-formatted way. Mostly used for debugging purposes.
This command flushes the output buffer and stops the Tcl script from sending any more data to the client. A normal Tcl script might use the exit command, but that cannot be used in Rivet without actually exiting the apache child process!
This command is useful for situations where it is necessary to only return HTTP headers and no actual content. For instance, when returning a 304 redirect.
Scans through each character in the specified string looking for special characters, escaping them as needed, mapping special characters to a quoted hexadecimal equivalent, returning the result.
This is useful for quoting strings that are going to be part of a URL.