This really is a shell. You can change directories, print the working directory, copy files, remove files, and so forth, using the usual Unix commands. You can use the exit command to leave the program. One thing that makes Tcl interesting is the number and variety of extensions that are available. Tk is a set of extensions that provides the ability to create GUIs in an X Window environment. These extensions make it easy to develop graphical interfaces for tools. Tk can be invoked interactively using the windowing shell wish. Both Tcl and Tk are implemented as C library packages that can be included in programs if you prefer. scotty, primarily the work of Jürgen Schönwälder, adds network management extensions to Tcl/Tk. The tnm portion of scotty adds network administration support. The tkined portion of scotty, described in the next section, is a graphical network administration program. What tnm adds is a number of network management commands. These include support for a number of protocols including ICMP, UDP, DNS, HTTP, Sun's RPC, NTP, and, most significantly, SNMP. In addition, there are several sets of commands that simplify writing network applications. The netdb command gives access to local network databases such as /etc/hosts, the syslog command supports sending messages to the system logging facilities, and the job command simplifies scheduling tasks. A few examples should give an idea of how these commands could be used. You can invoke the scotty interpreter directly as shown here. In this example, the netdb command is used to list the /etc/host table on a computer:bsd2# tclsh8.2 %
The results are returned with each entry reduced to the canonical name and IP address in brackets. Here is the host table for the same system:bsd4# scotty % netdb hosts {localhost.lander.edu 1.0.0.127} {bsd4.lander.edu 239.63.153.205} {bsd4.lander.e du. 239.63.153.205} {bsd1.lander.edu 231.60.153.205} {sol1.lander.edu 233.60.153 .205} {lnx1.lander.edu 234.60.153.205} % exit
Note that there is not a separate entry for the alias bsd4. Here are a few examples of other commands. In the first example, the name of the protocol with a value of 1 is looked up in /etc/protocols using the netdb command:bsd4# cat /etc/hosts 127.0.0.1 localhost.lander.edu localhost 205.153.63.239 bsd4.lander.edu bsd4 205.153.63.239 bsd4.lander.edu. 205.153.60.231 bsd1.lander.edu bsd1 205.153.60.233 sol1.lander.edu sol1 205.153.60.234 lnx1.lander.edu lnx1
In the second example, a reverse DNS lookup is done for the host at 205.153.63.30:% netdb protocols name 1 icmp
Finally, an ICMP ECHO_REQUEST is sent to www.cisco.com:% dns name 205.153.63.30 sloan.lander.edu
The response took 321 ms. Other commands, such as snmp, require multiple steps to first establish a session and then access information. (Examples are given in Chapter 7, "Device Monitoring with SNMP".) If you are interested in using these tools in this manner, you will first want to learn Tcl. You can then consult the manpages for these extensions. A number of books and articles describe Tcl, some of them listed in Appendix B, "Resources and References". The source is freely available for all these tools.% icmp echo www.cisco.com {www.cisco.com 321}
6.3. Device Identification | 6.5. Mapping or Diagramming |
Copyright © 2002 O'Reilly & Associates. All rights reserved.