Sensors and network administering


Network Test Automation with Mac OS X and Tcl

Your company has just invented thebut allows you to easily edit files in
hottest new web server to hit thethe Darwin file system.
market. You created a killer test planEmacs running native under Mac OS X
in Adobe Illustrator with breathtakingenvironment
diagrams of your test networkEmacs contains most of the features you
environment on Macintosh G4 running Macwill require for editing programs in the
OS X. Wouldn't it be great if you couldDarwin environment. But Emacs can be
run tests from your Mac too? Well ...difficult to use. The hidden keystroke
you can!commands are particularly annoying. For
If you haven't been introduced already,example, you must use control (^)x^s to
the Tool Command Language, Tcl, is asave a file. The Aqua-on-Emacs port
secret weapon used by large networkdoes, however, provide a nice menu bar
hardware corporations to test theirto assist you if you're not familiar
devices. It's an extremely flexiblewith the editing environment.
scripting language that has been portedNow that you've set up your rootless
to nearly every operating system inenvironment and have your editor
existence, and that now includes Mac OSinstalled, we can fire up Tcl.
X.Tcl is an installed package on Mac OS X
As wonderful as it is, Tcl isn't perfectmachines. However, Apple didn't include
all by itself. That's why I'm also goingExpect, or Tk (X11 tool kit for Tcl).
to discuss Expect, which is an extensionDon't ask why. Not a real problem
of Tcl that allows interactivethough. Michael Peters has provided an
automation to your Tcl scripts. Forexcellent port of Expect 5.32 which
instance, using Expect you can automaterequires Tcl 8.4a2 -- a revision
telnet sessions, database queries, anddifferent from Apple's. You'll need to
file transfers.download and install these two
For some reason, Apple didn't includecompressed packages to start using
Expect in its operating system release.Expect.
Not to worry, Expect has been ported toThe downloadable file is a StuffIt .hqx
Mac OS X, and I'll walk you through thefile. Once downloaded, the image
install of this handy extension.decompresses to a mountable disk image.
Utilities that you will needYou will need to use the Disk Copy
First I'll introduce you to a fewutility in the Applications/Utilities
utilities that I recommend you installfolder to mount the .img file.
on your test network workstation. NearlyMounting the Tcl and Expect images
everything is available on the Net --The mounted image is an installation
most of it from those diligent codepackage that you will need to
porters involved with the open-sourcedouble-click in order to start the
sourceforge.net project.installation. Remember, the new Tcl
With the current economic trends, yourinstallation is required for the Expect
manager will be pleased to know that youinstallation.
set up an awesome workstation usingThe Tcl 8.4a2 folder contents
mainly open-source applications. TheUnfortunately, the Expect and Expect Tk
focus here is creating an automated test(the graphical user interface and
environment running on Mac OS X.toolkit) portion of the package has yet
However, the same concepts will apply toto be tackled for Mac OS X. In a network
any Unix workstation -- thanks, again,test environment, we can survive with
to open-source efforts.command-line scripts. But I know how
Rootless X on Mac OS Xexcited your manager gets when you show
To begin, I recommend that you installthem a GUI application. If you were
Rootless X.adventurous enough to port Expect Tk, or
Torrey Lyons has released a rootlessknow where a working image is hiding,
version of XFree86 for Mac OS X. Iplease let us know in the O'Reilly
provided installation instructions for XTalkBack section for this article. In
on X in a previous O'Reilly article,the meantime, we're command-line
Installing XFree86 on Mac OS X .constrained.
Torrey's rootless XFree86 is availableInvoking Tcl
from sourceforge.net (X on X). XFree86Comment on this articleAfter having
will soon become indispensable as youworked with Michael's Tcl examples, let
put together your test automationus know what you think or where you got
system. The fact that your Mac OS Xstuck.
machine is running rootless allows youPost your comments
to run the XFree86 desktop and the MacTcl is a simplistic language that is
OS X desktop in the same window. Priorstring-based. You can invoked Tcl by
to this, you were required to toggleexecuting the command tclsh from your
between the two desktop environments.terminal or console window. A simple
See Figure 1."Hello World!" script looks like this:
The examples listed later in thisSpongebob # tclsh
article will also run in the Mac OS X% set myString "Hello World!"
console window utility. But in myHello World!
opinion, life is a lot easier using the% puts $myString
X Windows environment with multipleHello World!
terminal windows opened. This featureThis code snippet demonstrates how Tcl
comes in handy when you're testinguses the set command to assign the
multiple network devices simultaneously,string value "Hello World!" to the
such as in a network system testvariable myString. Assigning a "$" in
environment.front of the variable, myString,
Emacs on Aquainstructs the interpreter that the
Many editors are now available for Unixscript is going to reference the value
environments; the two most prevalent arecontained there. In this example, the
vi and emacs. The Emacs-on-Aqua utilitystring value is "Hello World!". The puts
is a complementary tool to run with thecommand writes the value referenced to
rootless XFree86 environment. The Emacsthe terminal window.
utility executes in Mac OS X environment



1 A B C 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95