November, 2001: NT Internet Goodies

by Andy Bruce

In this issue, I'll cover a grab bag of great software available from the Internet for NT. I've had the opportunity over the last couple of months to search for a tremendous amount of free stuff, and I'm ready to share it all with you! Plus, another of my famous "personal goodies" for your enjoyment—this one to do with making pattern matching easier.

LoSOFT for HiQuality Software

I found another great site for free NT command-line tools at http://www.losoft.de/fs_software.html. This German company has provided some really nice tools for us NT folks, which I had the pleasure of trying out over the last couple of months.

I'll go over the most useful tools here. The package comes with other tools, but some of them (like clipdump.exe) simply don't add value over what you can do easily. However, you could make clipdump (which dumps clipboard information to the screen) part of a batch job so that command-line programs can use the clipboard to share data—hmm, sounds intriguing!

apm.exe—A good tool for those with laptops (or even without them). I ran this command on my desktop machine with the /s (suspend) option, and the computer did immediately suspend itself. And by "immediately," I mean immediately. This is kind of scary, but effective.

copytosystem.exe—This handy utility makes it simple to copy files to the appropriate System directory without going to the trouble of reading through environment variables. This is an interesting program that you can use to make some types of installation scripts easier to write. (Although I must say that, in general, I strongly disapprove of applications copying DLLs to the System directory—I've come to much grief in the past with that approach. Many thanks to Microsoft and its habit of releasing non-compatible "upgrades" to common, shared DLLs!)

down.exe—This flexible program allows you to shut down the local machine, or a remote machine. I'm in slight shock at the magnitude of this application, since it:

The scope of this program goes far beyond what I would expect from a freebie.

errortext.exe—This is another useful tool, especially for command-line applications. Have you ever wondered what a specific error code means (such as the infamous 10055 sockets error)? This application has all the Windows error codes in it, along with their error text. I can think of immediate uses for this feature in some of my own scripts. In many cases, I get an error code from a failed command and simply display it; now I can call errortext.exe and get the actual text for the error.

ln.exe—A great program that allows you to create true UNIX-style "hard links" for files on NTFS drives. (I certainly hope all your drives on your computer are NTFS!) While other toolkits (such as MKS) allow you to do this, I've yet to see another freebie that performs this function with such a small footprint. Cygwin, for example, supports links but requires a larger install. (Also, the Cygwin hard links appear not to use NTFS capabilities; in effect, they appear to be "software-only" links you can see only from a Cygwin shell.)

One question you may have: What is a hard link and why is it useful? The answer is that hard links allow you to have the same file in multiple directory locations. And, by "same file" I mean "same file"! As in, when you change one, the other changes automatically. I find links especially useful in the UNIX world when I want a reference in one directory to a binary existing in another directory. In the Windows world, you'd have to copy the file, while UNIX allows you to set up a "link" so that whenever you change the binary (for instance, by recompiling it) you don't have to recopy it. While UNIX supports two types of links (hard and soft, the differences between which I won't go into here), by using the ln.exe tool from LoSOFT you can get much the same functionality.

setenv.exe—This is the program that caught my eye! How many times have you needed to write a script that changed the PATH for the calling program or script? In other words, you want to call a script from your application and make changes to the environment for the caller? If you've tried to do that, you know how hard it can be on NT. (Simply changing the environment in a child, or spawned, process changes the environment only for the child process itself.)

Honestly, I don't know how these guys did it (I haven't done the research to find it out), but I'm quite grateful for the work they've done. I highly recommend this utility, and will use it myself to make my own scripts easier to process.

who.exe—This tool adds some nice features to the existing who you might use from other UNIX toolkits. I ran the software with the /A (all info) switch and got this set of data:

Copyright (c) 1997-2001 LoSOFT Softwaretechnik
Freeware. Newest Version at http://www.losoft.de/

Account:    ENG\abruce on JMILSAPPS01
Sid:        S-1-5-21-790525478-1965331169-725345543-1961
Name:       Andy Bruce
Comment:    Limited Access Account (SoftWorks)

Groups:     M = mandatory    O = can take ownership
            D = disabled     F = only used to deny access

  00 [M]   ENG\Domain Users
  01 [M]   \Everyone
  02 [MO]  BUILTIN\Administrators
  03 [M]   BUILTIN\Users
  04 [M]   ENG\eccesm
  05 [M]   ENG\Engineering
  06 [M]   \LOCAL
  07 [M]   NT AUTHORITY\INTERACTIVE
  08 [M]   NT AUTHORITY\Authenticated Users

Privileges: E = enabled     D = enabled by default

  00 [DE] SeChangeNotifyPrivilege
  01      SeDebugPrivilege
  02      SeSystemEnvironmentPrivilege
  03      SeSystemProfilePrivilege
  04      SeProfileSingleProcessPrivilege
  05      SeIncreaseBasePriorityPrivilege
  06 [E]  SeLoadDriverPrivilege
  06      SeCreatePagefilePrivilege
  08      SeIncreaseQuotaPrivilege
  09 [E]  SeUndockPrivilege
  10      SeTcbPrivilege

Compare that to the output I get from running the built-in who provided with MKS:

abruce_beta2_13 : jmilsapps01> who -a
Name             ST Line         Time          Idle     PID Comment
abruce            ? CONIN$       Sep  6 09:19   old    1992

Anyone who must provide system administration support will find the wealth of information from this program invaluable. I especially appreciate the list of privileges the user has, since in many problem cases it's exactly these privileges (or the lack of them!) that cause problems.

And now that I've gotten so much good material from these guys, the least I can do is give a quick plug for their product NetExec. (No, I'm not associated with this company in any way, and it won't gain me a cent or make a bit of difference to me whether you order their software or not!) The NetExec product allows you to run commands as a different user. And while 2000 comes with a Run As command that does the same thing, the people at LoSOFT have raised the bar with their offering. For example, you can do things from the command line that Microsoft doesn't even consider offering. And at only $30 for a single-user license, the software almost falls into the "free" category itself!

Tales from the Encrypt

My good friend Joseph Berry turned me onto some great free encryption software: E4M (Encryption for the Masses) at http://www.e4m.net/. Even the title itself is in the purest Internet style with its implications of personal freedom and empowerment. I certainly hope that citizens in not-so-free countries can use this software to keep their private information Private!

One thing that turned me off from the start was the need to register for this encryption software. I kept thinking: who's keeping up with this? Is there some kind of record of who gets this type of encryption tool? I know it sounds paranoid, but the whole concept of this type of application is privacy, yes? So, in the interests of my Fellow Humanity, you can avoid the registration by using http://www.drivecrypt.com/update/home.asp, login e4m, and password freedownload. There! I hope I've done my part to keep the world a more Private Place.

Once downloaded (tiny at 440 K), you first begin by creating a volume. The logic is simple in concept: you create a file using the E4M "Create Volume" wizard. This file has a .vol extension, and double-clicking it allows you to mount it to a drive letter. From that point on, you can treat it as a regular drive. You can copy files to it and from it, and even run entire applications on it. (Although that's generally kind of silly; this type of application is better used to keep sensitive data rather than executables themselves.)

The whole application worked like a charm, but I still have some questions I couldn't find answers to. The main one is true protection. Keep in mind that once you mount a volume, it's just like any other drive. You can share the drive out. You could leave your computer while the drive was available in your Windows Explorer, and someone else could simply copy your sensitive files to a floppy. So, I started looking for some type of "timeout" value. (While timeout values in themselves aren't perfect, they're much better than nothing.) I couldn't find anything, which means that if you do mount a drive, you'd best remember to unmount it before you leave your computer for any length of time. And as for sharing: IMHO this type of application should require some sort of special verification prompt before allowing you to share any portion of your encrypted volume.

Apart from my paranoid nit-pickings, this is a great product and I'm using it myself to store my "Dear Diary" entries written at 3 a.m. ;-).

The Check's in the Mail...

Call me absent-minded, but over the last three months I've lost two checkbooks. (Yes, I know, nobody has a clue what kind of dinosaur still uses a checkbook!) So, I've finally broken down and decided to Get Organized. And while I could simply spend a few bucks to get some great financial software—well, this is the Internet Generation! I never pay for anything if I can get it for free! So it's off to the search engines for (you guessed it) "free personal financial software".

What Price Freedom?

The first thing I noticed is that many hits from my "free" search is that a bunch of the major players all use this word to define their (definitely not free!) software. Took a bit of the wind out of my sails. Just for fun, I looked up one vendor's personal finance software price: $59.95! Since all I want is a check register (a simple Excel spreadsheet would probably be sufficient), I know I can do better than that.

To keep things interesting, I decided that only free software would qualify. I simply can't see the point of paying money for this type of record keeping. In fact, if I owned a bank one of the first things I would give away would be a free electronic check register. The result of my high-minded (and off-topic for this article) search was to burn several hours scanning search lists—and after that time I found only two applications that even came close to what I wanted.

PennyPincher 2.5 (freeware, http://www.geckostudios.com/pennypincher/)The first thing I noticed about this program was the advertising banner—which can't be turned off. Despite this fact, the program is simple to install and use. In fact, it's probably too simple. Nowhere could I find how to indicate that various checks have cleared (in order to help resolve "bank" vs. "real" balances). It's possible to export the program data to an ASCII text file, but the exported text is of almost no use whatsoever. The program does come with a free chart to show you where you spend your money. Not terribly exciting.

Just Write Checks 2.1 (freeware, http://www.justwritechecks.com/)This is an interesting program if you (literally!) want to write your own checks. As kind of an afterthought, you can also enter all the data you normally would to a check register. But still a pretty lame effort.

Moral: There's definitely a hole in the market for cheap, shareware-based personal financial software if you want to write it. And in my case, I simply looked for and found a freebie Microsoft Excel spreadsheet I could muck with. But that's another story.

Another Personal Goodie: The Log Engine

Over the course of the last year I've spent an enormous amount of time in various log files. As I identified various problem scenarios, I was able to create a set of expert-system style rules that I could apply manually. I wanted to automate this process, but I couldn't find a tool that made sense. (Writing pattern-matching scripts using the awk application was my best bet, but I couldn't count on awk being installed on the machines I would be on.) So I wrote my own "poor-man's awk" using Perl so that I could apply my library of expert-system rules to log files automatically.

Keep in mind that the heart of any major software application is the log file. A good log file provides (in the best examples) a clear record of what events occurred, and what program logic executed as a result of the events. A good log file can also take an extremely difficult scenario, such as keeping up with multiple simultaneous threads, and make it relatively easy to interpret.

The basis of this month's goodie is the premise that log files exist to track discrete, atomic events (in a word-expert-system rules). For example, one such event might be when one node initializes itself to another node on the network. In this case, several transactions may occur while the initialization is in progress. The initialization as an event is the sum total of the various transactions (and program logic) that make up the interaction between the two nodes. For example:

Node A

            Initialization Sequence

   Node A                       Node B
____________________________________________
Send INIT
                              Recv INIT
                              Process Data
                              Send Notification 1
Recv Notification 1
Send Response
                              Recv Response
                              Send Notification 2
Recv Notification 2           Send INIT Response
Recv INIT Response

In the example, we can see that a single INIT from Node A to Node B actually consists of multiple steps. If any of the steps fail, then the INIT as a whole fails. Once you've identified all the elements that make up the INIT, you have your expert-system rule-and, using the tool I wrote, you can automate the process of verifying a given log file.

Using a tool such as grep won't do the job, because we're not looking for single phrases. Rather, we're looking at interpreting many different combinations of output lines in order to state unequivocally that a particular action passed or failed. In other words, the log engine package exists to allow you to automate all the manual procedures you'd normally make to analyze a given log file.

I've attached the log engine package to this month's article; download it by clicking on the link in the righthand panel. The package itself consists of the (very large!) Perl script, plus some documentation. You install the package simply by unzipping the archive to a directory of your choice, and then running the logengine.bat script. (You need to run this command from a command prompt and you must be in the directory where you installed the package.)

You'll need to make sure you have a modern version of Perl installed (I strongly recommend the latest Perl from http://www.activestate.com/).

This goodie includes these basic features:

I use this tool all the time now to analyze many different types of files; in short, any file that has complex patterns that I must analyze carefully to identify a specific result. I certainly hope you find it as useful as I do!

Next Time

I'm doing some work with the Enhydra Web-enabled application development system. Enhydra (http://www.enhydra.org/) is an exciting Open Source project underwritten by the folks at Lutris (http://www.lutris.com/products/index.html), and enabled with the help of the GNU project (http://www.gnu.org) and Cygwin (http://sources.redhat.com/cygwin/). Specifically, I've been working on "servlets," which are sort of like CORBA server-side objects on Internet steroids! I hope to have a lot of information on this free and useful software so that you can apply it in your own shop. Until then, surf safely.

Andy Bruce has been writing software for various operating systems and assorted languages for more than 12 years. He is a primary author of several shrink-wrap products, including Landmark Systems' PerformanceWorks suite and Savant Corporation's Q for Oracle. He also has written many courses in computer programming for McGraw-Hill NRI. He lives and works in the Washington, D.C. area.