Channels ▼
RSS

Out of the Shell


Out of the Shell

I’m not old, or even particularly crotchety—honest. It’s just that I cut my teeth on Unix timesharing systems. (Of course, I was weaned on a Univac that sported a row of eight lighted switches and a large one labeled “LOAD.”) Unix was built by programmers for programmers, and the toolset they built up shows it. I got very comfy in that environment.

When I moved to DOS boxes for development, I wasn’t a fish out of water—it was more like a fish chucked into orbit. Certainly, my blood boiled. Witnesses heard the strangled cry—“Where’s grep? There’s no GREP?”—just before I exploded. Fortunately, someone had acquired Mortice Kern Systems’ Toolkit, and installing it mellowed me considerably. I had my grep, my find, even rlogin—and could return to editing with vi.

Still Kickin’

Fast forward a few years, and a company called MKS is known mainly for high-end configuration management systems—but the Toolkit lives. Its primary goal remains the same: Developers and administrators working on Microsoft operating systems access should root through the same bulging toolbox toted by their Unix brethren. Even if you’re not already Unix-compatible, you owe it to yourself to see what we shell-heads are always going on about.

A note on the term Unix: I’m probably going to get Darl McBride on my case here (not that SCO actually owns the trademark, but on the form to date, I doubt that’ll stop him). But in this review, I’ll use Unix fairly loosely, meaning “that entire family of more or less Posix-compatible operating systems, including Linux, HP-UX, AIX, Solaris and BSD that support the tools we’re talking about.” See The Open Group’s website (which does own the trademark) for the Unix scoop: what it is, where it came from, what flavors came when and more.

The Toolkit’s core is a collection of 400-plus command-line utilities—Windows EXE files adding up sufficiently close to the whole Unix ball of wax that most shell scripts should run without hair-pulling. Toss in a few value-added GUI tools and a docs set, and you’ve got the Toolkit for Developers. (MKS also sells a Toolkit for Professional Developers that adds GUI libraries to mimic the Unix APIs, letting you port nongraphical programs from Unix to Windows; the Toolkit for Interoperability that adds an X server so that ported X Window programs can run on your Windows box; and the Toolkit for Enterprise Developers tacks on the libraries necessary for GUI programming.)

The Nuts and Bolts

At the risk of inducing a coma in programmers already familiar with the Unix environment, I’ll give you a taste of what it’s like to work there; without attempting to replicate the manuals or even list all 400 programs, here’s a fast highlights reel of the kinds of tools included and what they’re good for. (You can peruse the entire list at the MKS website).

If you’re accustomed to working in complex integrated development environments like Visual Studio or JBuilder, the Unix tool philosophy will seem paradoxical, even primitive. The environment is a naked command line, and in place of one program offering every conceivable feature, there are 300 to 400 single-purpose programs. In practice, this turns out to be an incredibly powerful way to work—as long as you manage to remember what most of the tools do. For example, suppose you were building a test script and needed to insert into your source code a list of all the DAT files in a folder containing today’s date. It’s a one-liner with Unix tools; the line you type into the vi editor is “simply” :r !grep “`date +\%D`” *.DAT.

A command-line environment obviously requires a command line—MKS provides four of the most popular interpreters. Every Unix system worthy of the name offers a shell compatible with the Bourne shell, and the Toolkit follows that lead with the Bourne Again (bash) shell beloved of Linux-heads. The venerable C shell is also available, as well as the somewhat newer Korn shell. Given a choice, most of us would rather work in bash, but since every shell tends to spawn a universe of scripts, it’s important to support even those that aren’t as popular. The fourth shell is tclsh, which is even more specifically aimed at scripting rather than interactive use. The Tool Command Language supports general-purpose programming and can be combined with the TK library and an X server (neither of which, sadly, are shipped with this edition of Toolkit) to add GUIs to your scripts.


[click for larger image]

Discovering Difference
MKS Toolkit’s Visual Difference tool lets you find and merge differences between files.
For text searching and manipulation, grep is a powerful, regular expression-based searching tool. The “stream editor” sed is a full-featured, line-oriented text editor that can be inserted in the middle of a pipeline. For more sophisticated logic constructs based on pattern matching, use the Awk or Perl languages (and a2p converts scripts in the former to the latter). For finding and merging differences between files, MKS provides the text-based diff, diffb (compares binary files), diff3 (performs a three-way compare), patch and the Visual Difference tool (see “Discovering Difference”).

Programming tools per se include a front end to the Microsoft C compiler cl.exe that lets it masquerade as a Unix-style cc; the ctags tool builds a database from source code that lets text editors like vi function as a primitive version of today’s source-code browsers. The Toolkit includes the ex line-oriented programming editor, as well as its slightly more modern buddies vi (a full-screen editor that can run in a command-line terminal window), vim (Vi IMproved) and a GUI version of viw.

For archiving and backup, there are utilities to munch directory structures into file streams suitable for storing or dumping to tape (tar, cpio, pax) and a tape-drive control program (mt), as well as compression/decompression utilities for Lempel-Ziv, ZIP or Burrows-Wheeler block-sorting formats (bzip, compress, gzip). You can schedule such backups (or any other job, for that matter), using MKS’s front end to the Windows task scheduler (see “The Front End”), or in the traditional Unix edit-the-config-file style with crontab. There’s also an at command to set up a single command for delayed execution.

Of course, Unix and networking have been synonymous for years, and MKS doesn’t leave you isolated. They include the old-style remote-shell (rsh) tools; these days, though, you should use them strictly for backward compatibility. Use secure-shell tools (ssh, scp, sftp) instead, since they provide convenient no-password login from machine to machine without the security exposures of rsh, rlogin and rcp. A goodly complement of SNMP tools is also provided, along with tools to fetch and read mail from both POP3 and IMAP servers.


[click for larger image]

The Front End
You can schedule such backups (or any other job), using MKS’s front end to the Windows task scheduler.
There’s plenty more, of course—Unix favorites like find (a tool that recurses through directory hierarchies looking for files and running commands on them), Windows-specific tools like registry for reading and editing the Windows registry from the command line, and just-dang-useful utilities like htstrip, a filter that removes HTML tags from its input stream and sends the result to its output.

In Practice

Installing the Toolkit is simple, though surprisingly enough for such a mature product, there are rough edges. For example, trying to run the secure-shell utilities generates an error message that a .ssh directory could not be created. Was I the first to encounter this problem? The installation also sets up the rlogin and telnet servers to run without so much as a confirmation box, leaving you with open ports on your machine (although the servers don’t appear to allow anything heinous like unrestricted logins). And if you attempt to run the terminal emulator installed on the Start menu, it exits with an error message comprehensible only to X Windows aficionados. Of course, this product is aimed primarily at developers already familiar with Unix, but what of nonmigrants who merely wish to exploit the fabled power of Unix? Just because the tools hail from Unix ancestors doesn’t mean the package needs to drag along Unix’s stereotypical baggage of cryptic UIs to which only real gurus need apply.

What About Cygwin?

Now let me speak to that vocal crowd in the back row who’ve been hollering, “What about Cygwin?” What about it, indeed. Back in the mid-’80s, MKS was about the only game in town for Unix-heads working in (I almost said “stuck in”) DOS. In the early ’90s, however, programmers at a company called Cygnus began work on an open source alternative. Today, the Cygwin tools are available for free download at http://cygwin.com, and you’ll recognize nearly the same cast of characters: awk, csh, grep, find, ssh and hundreds more.

So what does the MKS Toolkit give you for the money? The Enterprise and Professional products enable you to port commercial code from Windows to Unix, free of the free-software encumbrances of the GNU license.


[click for larger image]

Cygwin Setup
Cygwin is easy to install, but it gives the user perhaps too much control—you can easily find yourself swimming among hundreds of packages, looking for the ones you need.
Cygwin’s licensing is a little confusing, however: Some of the code is released under the GNU license, some under the X license and some is actually in the public domain. For $25,000 a year—or $50,000 for three years—you can buy a commercial license from Red Hat for redistributing software built with Cygwin without releasing your source code under the GPL.

Some of the Windows-specific tools like registry aren’t in the Cygwin toolkit, nor are MKS’s SNMP tools, nor the GUI utilities: the task scheduler, visual difference, arbitrary-precision calculator, process-status display, grep front end, free-disk-space display or pax backup GUI.

MKS also provides a documentation set for the command-line tools navigable via your choice of the venerable man interface or a Windows help file. In either case, the content is essentially the same—if you hate man pages, you won’t like the help files much. One significant advantage? The various cross-references and “See Also” items are live hyperlinks.

Cygwin is relatively easy to install, but in contrast to MKS’s slap-in-a-CD process, Cygwin gives the user perhaps too much control—the newbie can easily find himself swimming among hundreds of packages, looking for the ones he might need (see “Cygwin Setup”). But once past that hurdle, the Cygwin downloader winds up with a Unix toolbox for no money down. It took me about 45 minutes to download and install everything over a 768Kb per second DSL line. If counting EXEs is your bag, know that Cygwin provides over 1,400 programs, and some of those are pretty significant: the complete Gnu Compiler Collection (including C, C++, Fortran and Java), an X Window server and a host of clients for it, and the Emacs programming editor.

The full Cygwin install furnishes its own documentation set in HTML, libraries for creating Windows command-line or GUI applications, and the source code for the whole ball of wax. Red Hat will also sell you a commercial, supported version of the utilities starting at $2,679 for 10 desktops. As stated previously, pricing for deploying a commercially licensed (that is, non-GPL) application linked against the Cygwin libraries starts at $25,000 per year.

Whether the MKS Toolkit is worth the money depends on your situation. If you’re administering servers and have both Windows and Unix-type machines in the mix, the Windows-specific tools clearly justify buying the product. If you’re primarily doing development, don’t need support, and just need the utilities, save your money: Cygwin brings you a lot closer to the full Unix command set, and they throw in the source code for free.

MKS Toolkit for Developers 8.6
MKS Inc.
410 Albert St.
Waterloo, ON Canada N2L 3V3
Tel: (800) 637-8034
Fax: (703) 803-3344
www.mkssoftware.com

Pricing Scheme:

$479 (developer license, includes 1 full year of support)

Technical Requirements

Windows Me, NT 4.0, 2000, XP and Server 2003

Rating: 3 stars The Rate Sheet
Pros:
  1. The toolkit provides the core “gotta-have-’em” Unix tools.
  2. Server admins will like the Windows-specific management utilities.
  3. MKS includes an extensive documentation set, plus one year of phone and update support.
Cons:
  1. Even a vanilla install can lead to confusing error messages.
  2. Fewer command-line tools are provided than in the open source alternative.
  3. Programming libraries, X Window Server are extra-cost add-ons.

Rick Wayne has way too much fun with Web-enabled ecosystem management software for the University of Wisconsin. E-mail him at fewayne@facstaff.wisc.edu.


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 

Video