Reference Manual


tcl - Tcl 6.7 Tool Command Language interpreter, with extensions
tcl [filename]
This NAT32 adaptation of John Ousterhout's Tool Command Language supports many features of TCL as described in "Tcl and the Tk Toolkit" (Addison-Wesley 1994).

Tcl can be invoked from the NAT32 shell with an argument specifying the filename of a Tcl Script.

Tcl can also be invoked by simply entering a filename directly to the shell, if that file contains the string #!tcl in its first line. Arguments are passed as expected.

Not all of the Tcl exec and open options have been ported.
SNMP Tcl commands are:
snmp agent
snmp next
An agent must first be specified, either as a domain name or as an IP address. A list of object names (or object IDs) can then be specified. For example:
snmp agent
snmp system.sysUpTime
snmp next
TCP support consists of a socket command for creating a socket object. Two variants exist, the first for creating a passive socket, the second for creating an active socket:
socket -p service [qlen]
socket host port
Each variant returns a socket descriptor which can be used as follows:
set s [socket -p 8000 1]
The above command creates a socket object s which listens at port 8000 and uses a listen queue of length 1.

To open a TCP connection to a remote host, the second variant of the socket command is used:

set s [socket 80]
The above command creates a socket object s which is a TCP connection to port 80 at In both cases, once a socket object has been created, the following methods are supported for using that object:
{object} accept         # accept an incoming connection

{object} getf fname     # copy incoming data to file fname
{object} gets len       # read len incoming bytes

{object} putf fname     # copy file fname to the connection
{object} puts var       # write var to connection

To close a socket, one deletes the socket object using the standard Tcl rename command:
rename $s {}
A complete example is shown in file httpd, a simple but powerful HTTP server.
httpd, sh, shell, snmp, Tutorial