| Your company has just invented the | | | | but allows you to easily edit files in |
| hottest new web server to hit the | | | | the Darwin file system. |
| market. You created a killer test plan | | | | Emacs running native under Mac OS X |
| in Adobe Illustrator with breathtaking | | | | environment |
| diagrams of your test network | | | | Emacs contains most of the features you |
| environment on Macintosh G4 running Mac | | | | will require for editing programs in the |
| OS X. Wouldn't it be great if you could | | | | Darwin 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 a | | | | save a file. The Aqua-on-Emacs port |
| secret weapon used by large network | | | | does, however, provide a nice menu bar |
| hardware corporations to test their | | | | to assist you if you're not familiar |
| devices. It's an extremely flexible | | | | with the editing environment. |
| scripting language that has been ported | | | | Now that you've set up your rootless |
| to nearly every operating system in | | | | environment and have your editor |
| existence, and that now includes Mac OS | | | | installed, we can fire up Tcl. |
| X. | | | | Tcl is an installed package on Mac OS X |
| As wonderful as it is, Tcl isn't perfect | | | | machines. However, Apple didn't include |
| all by itself. That's why I'm also going | | | | Expect, or Tk (X11 tool kit for Tcl). |
| to discuss Expect, which is an extension | | | | Don't ask why. Not a real problem |
| of Tcl that allows interactive | | | | though. Michael Peters has provided an |
| automation to your Tcl scripts. For | | | | excellent port of Expect 5.32 which |
| instance, using Expect you can automate | | | | requires Tcl 8.4a2 -- a revision |
| telnet sessions, database queries, and | | | | different from Apple's. You'll need to |
| file transfers. | | | | download and install these two |
| For some reason, Apple didn't include | | | | compressed packages to start using |
| Expect in its operating system release. | | | | Expect. |
| Not to worry, Expect has been ported to | | | | The downloadable file is a StuffIt .hqx |
| Mac OS X, and I'll walk you through the | | | | file. Once downloaded, the image |
| install of this handy extension. | | | | decompresses to a mountable disk image. |
| Utilities that you will need | | | | You will need to use the Disk Copy |
| First I'll introduce you to a few | | | | utility in the Applications/Utilities |
| utilities that I recommend you install | | | | folder to mount the .img file. |
| on your test network workstation. Nearly | | | | Mounting the Tcl and Expect images |
| everything is available on the Net -- | | | | The mounted image is an installation |
| most of it from those diligent code | | | | package that you will need to |
| porters involved with the open-source | | | | double-click in order to start the |
| sourceforge.net project. | | | | installation. Remember, the new Tcl |
| With the current economic trends, your | | | | installation is required for the Expect |
| manager will be pleased to know that you | | | | installation. |
| set up an awesome workstation using | | | | The Tcl 8.4a2 folder contents |
| mainly open-source applications. The | | | | Unfortunately, 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 to | | | | to 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 X | | | | excited your manager gets when you show |
| To begin, I recommend that you install | | | | them a GUI application. If you were |
| Rootless X. | | | | adventurous enough to port Expect Tk, or |
| Torrey Lyons has released a rootless | | | | know where a working image is hiding, |
| version of XFree86 for Mac OS X. I | | | | please let us know in the O'Reilly |
| provided installation instructions for X | | | | TalkBack 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 available | | | | Invoking Tcl |
| from sourceforge.net (X on X). XFree86 | | | | Comment on this articleAfter having |
| will soon become indispensable as you | | | | worked with Michael's Tcl examples, let |
| put together your test automation | | | | us know what you think or where you got |
| system. The fact that your Mac OS X | | | | stuck. |
| machine is running rootless allows you | | | | Post your comments |
| to run the XFree86 desktop and the Mac | | | | Tcl is a simplistic language that is |
| OS X desktop in the same window. Prior | | | | string-based. You can invoked Tcl by |
| to this, you were required to toggle | | | | executing 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 this | | | | Spongebob # tclsh |
| article will also run in the Mac OS X | | | | % set myString "Hello World!" |
| console window utility. But in my | | | | Hello World! |
| opinion, life is a lot easier using the | | | | % puts $myString |
| X Windows environment with multiple | | | | Hello World! |
| terminal windows opened. This feature | | | | This code snippet demonstrates how Tcl |
| comes in handy when you're testing | | | | uses the set command to assign the |
| multiple network devices simultaneously, | | | | string value "Hello World!" to the |
| such as in a network system test | | | | variable myString. Assigning a "$" in |
| environment. | | | | front of the variable, myString, |
| Emacs on Aqua | | | | instructs the interpreter that the |
| Many editors are now available for Unix | | | | script is going to reference the value |
| environments; the two most prevalent are | | | | contained there. In this example, the |
| vi and emacs. The Emacs-on-Aqua utility | | | | string value is "Hello World!". The puts |
| is a complementary tool to run with the | | | | command writes the value referenced to |
| rootless XFree86 environment. The Emacs | | | | the terminal window. |
| utility executes in Mac OS X environment | | | | |