May, 1999 - NT Internet Goodies
by Andy Bruce
Before I begin, let me go ahead and state that a complete UNIX package is available from Mortice-Kern Systems (MKS Toolkit, $399, all Windows platforms, http://www.mks.com/)I have their toolkit, and it's nice enough. However, it ain't free, and it doesn't have everything you might need. So let's get going.
Telling the Net About Telnet
I started with a practical problem I wanted to solve. I have 95, 98, and NT 4 all on my local network. I also do a lot of remote work, both onsite at my clients' (for files I left at my office) and at my office (to check files in, perform system builds on a remote computer, etc.). My solution up to now has been to use RAS (Remote Access Server) on NT.
While RAS works, it's really slow, and for obvious reasons. Let's say that I want to execute a program to check out a source file for modification. I connect to the remote NT box using RAS, and double-click on the "checkout" program. RAS copies the executable file across the line to my local box (to a temp area), and then executes it. Since it's not uncommon for an executable to be many hundreds of KB, there's a substantial penalty involved. Also, I must make sure that any required shared libraries (DLLs) already live on my local box, or the program will fail. The end result is that I must make sure I have copies of necessary remote software on my local box--ugh!
Telnet's much better. With a Telnet session, I log onto the remote box, and any commands I issue are executed on the remote box. Only the screen output returns across the wire--typically, a tiny amount of text. It's easy to get a good, cheap Telnet client for NT (Van Dyke Technology's CRT at http://www.vandyke.com/ is nice at $30), but the important thing is to have a Telnet server for the remote system. And, no, NT doesn't come with one. (NT does come with an FTP service, however.) While Telnet isn't truly a UNIX-specific application, it certainly was difficult to come up with a free/cheap one for NT. Here's what I did find:
Fictional Telnet Daemon (free for personal use, fictional.net, http://www.fictional.net/). This daemon got good reviews on http://www.download.com/, and the price was right. Unfortunately, after installing the 2-MB+ data files and installing the service on my NT box, my Telnet client couldn't connect to the server--even running both on the same box! The author states that a simple e-mail will do to get technical support, but my time constraints limited me to solutions that work out of the box. Anyone have a success story with this product?
GoodTech Telnet Server for 95/98/NT (commercial: $20 for 95/98, $50 for NT, GoodTech Systems, http://www.goodtechsys.com/). This server has the lowest download size of any of the Telnet servers I found, and installed quickly and easily. The configuration was simple also, since the daemon uses standard NT logins (including domain name) to control user access. However, running my Telnet client against an NT server using GoodTech's daemon was noticeably slower than connecting to a Telnet daemon on, say, a Solaris box. It appears that the entire Telnet screen is returned and redrawn with each keystroke when connecting to the GoodTech daemon.
UWIN Telnet Daemon (free for individuals, AT&T, http://www.research.att.com/sw/tools/uwin/). This sounded promising. AT&T produces a "UNIX-to-Windows" solution that includes a Telnet daemon. However, I ran into many problems actually trying to download the UWIN package (you can't download the Telnet daemon by itself), so I'll have to leave it to someone else to do this product justice. But since the Telnet daemon is part of a much larger package, I suspect that installing and running the daemon won't be quite as easy as I'd like. On the other hand, the tools included with UWIN might make the extra trouble worthwhile!
Believe it or not, that's all I found. While there were some other commercial Telnet servers available, their price ($300+) precluded my even reviewing them.
This points something out to me. What I really want is a free, fast, easy-to-use Telnet server for almost any platform. So I guess I'll just have to write one (perhaps in Java, perhaps C++) and give it to the world. Let me know if you're interested in this--if so, I might be able to devote some column space in each issue to project status and interesting tidbits of information I uncover.
Vying for vi
Vi isn't a lukewarm product. You either love it or hate it--there isn't any middle ground. Personally, I find it appealing (no annoying hand movements for the mouse, no complex sequences of keystrokes as in Emacs). There turned out to be quite a few options available. And, yes, all of these applications had decent regular expression support, including:
:1,$g/^[<sp><tab>]*$/d // delete all blank lines :1,$s/.*/<tab>& // indent all lines one tab
Vim (free, http://www.vim.org/). This excellent program weighs in at 1,500 KB, but the options (and lack of price) are really nice. Syntax highlighting, GUI support, it's all there. While there aren't any pulldown menus in "GUI" mode, that doesn't matter to the true vi purist. One quibble I have is the lack of an installation program per se. Instead, you unzip the download file into the directory you want to run from. Then you run the install.exe file to set up the system path and to write a sample exrc file. And for 95/98 users, you must reboot the machine after running install.exe.
Lemmy ($20, http://www.softwareonline.org/). Another winner (although not free, and still 722 KB). I use this clone myself--I especially appreciate the unique syntax highlighter plugins. I can use it to write C++, Java, Tcl/Tk, HTML, etc. And it also has all the bells and whistles of Vim, plus pulldown menus (File, Edit, Help, etc.) if you want to use them. The application comes with a nice installation program, and doesn't require a system reboot.
Vile (free, ftp://ftp.clark.net/pub/dickey/vile). This little port comes in both console and windowed mode, but it offers no pull-downs. While it offers syntax highlighting, the highlighter is really just an external filter that (in the application's own words) has limited usefulness. However, it does have a nifty "ex" command mode processor. For example, when I wanted to change the tab stops from eight (the default) to four, the ex prompt intelligently changed as I typed in my command. At first, I typed : (colon) to enter ex mode, and the cursor moved to the bottom of the screen. Then I typed set and the bottom line prompt changed to Global value: . I then typed ts= and the bottom line prompt changed again to New ts value:. While this feature doesn't really add anything of value to the program, the fact that it's there makes me think that it's a well-thought-out and carefully crafted application!
Really, GNU's Not UNIX
The GNU project is massive and all-embracing. Between compilers, editors, operating systems, and utilities, the GNU project represents the single most comprehensive ongoing software development effort on the planet. The beauty of GNU is its decentralized development, just as the problem with GNU is its decentralized development. GNU is both a contradiction and a logical conclusion. GNU is what you make of it, or a state of mind, or both. Simply put, GNU's not UNIX.
More practically speaking from our perspective, the GNU project has provided a wealth of good utilities that work on many different operating systems. And by far the best single source I've found for GNU software (and Windows versions of UNIX software) is Virtually UN*X! (http://www.itribe.net/virtUNIX/).
Emacs (free, GNU project, http://www.fsf.org/). I downloaded this port from http://www.itribe.net/virtUNIX/emacs/. But be advised that you need both the precompiled binaries and the required data directories (two separate downloads). The best thing to do after the download is to read the readme (no file extension) program to see what other files you need. Once you get past the download hurdles, the program runs very well. I'm not a big Emacs user, but even I could see that everything is here. A great Lisp interpreter makes the difference for Emacs, and the interpreter provided with this port is fast.
Miscellaneous Utilities (free, GNU project et al, http://www.itribe.net/virtUNIX/mystuff.html). A neat little bundle on this page (1-MB download) contains many of the most common commands: ls, cp, mv, rm, gzip, tar, unzip, and more. While not every utility has 32-bit support (read, long file name support), enough do to let you get a lot done. But there are some problems. For example, the df utility reports the wrong size for each disk partition larger than 2 GB. (This is a bug in using the Windows API call GetDiskFreeSpace, and it requires an excruciating hack to get around it!) And some other utilities (such as ls) use a slightly different format than what I expected. However, tar was really quite nice and the effort as a whole appears well done.
Other Stuff (free, http://www.itribe.net/virtUNIX/otherstuff.html). There is a lot of really good UNIX software for free on this page. While there's more here than I can reasonably cover, I'll point out a couple of nice ones.
Less--less is more, and more is less. Sounds confusing until you try this little gem out. Bravo to the implementor! So many options, and so cool in the bargain. Somebody (I don't know who, I couldn't find credits) spent a lot of time on this application. Features like color coding and automatic vi entry mean that you'll never use more again!
Lots of tools for NT--some games (GNU chess, asteroids spinoff) and some other useful toys, most notably lex (lexical analyzer) and yacc (Yet Another Compiler Compiler...). Note that I didn't try any grammars against the yacc implementation, but I'll give it a spin very soon.
Cygnus (http://sourceware.cygnus.com/cygwin/download.html) provides a complete world of development utilities, including the bash command shell and all the "regular" UNIX applications. My main attraction to Cygnus was for its bash shell. The plain fact is that the DOS command shell (especially for 95/98, less so for NT) is ludicrously lame. For example, suppose I want to edit all files under the current directory (including subdirectories) that end with .INI. I can't do it. Not under any Windows platform, unless I write my own program. But under UNIX, it's trivially simple:
vi `find . name "*.INI" print`
The magic lies in the grave accents (back-tickmarks, usually located above the TAB key on a keyboard) that I wrapped around the find command. Using these tells the command shell to execute the inner command first and replace the inner command with its results. Thus, the inner find command might return the following:
./foo.INI ./dirone/bar.INI ./dirtwo/data/foobar.INI
The shell takes this result and replaces the find command with the file names, with the result that I can edit the files I want. I want a better command shell that handles this requirement, along with many other powerful UNIX shell features. Cygnus offers this, along with everything else I might need (including eCos, an embedded open systems operating system). Cygnus makes its money by providing commercial support for GNU applications, so the GNU software it provides is free.
When downloading information from Cygnus, you can choose either FULL (everything--a large download!) or USER (only the user tools). Since I primarily wanted the bash shell, I simply picked USER.
This went smoothly. I simply downloaded the appropriate file (a little over 3 MB, but with these kinds of utilities that really isn't a big deal) and then ran the downloaded file (it's a self-extracting executable). A full-fledged installation program appeared and led me through the process. Keep in mind that to install under NT you (apparently) must be logged in as Administrator.
Running the Shell
After installing the download, I had a new entry in my Administrative Programs menu for Cygnus Solutions; its only entry was for the bash shell. I started it, and it ran perfectly! No muss, no fuss. I could do all my favorite things, such as:
set o vi vi `find . name "*.INI" print`
The first command makes the command shell process keystrokes as though I was actually in vi. Mainly I do this so I can easily repeat commands by using the vi "line up" and "line down" commands, although I can also edit the current command using any of the vi keystroke combinations (after putting myself in command mode by pressing the <ESC> key). This in itself is worth a good deal to me, since no other NT port of a UNIX shell I have can do this.
The Telnet Test
While it's nice to have a good shell when running locally, it's absolutely crucial to have a good shell when running remotely. This is so because you need as much power as possible when you need to make every keystroke count. As an example, consider typing a long command name on a slow telephone line. It may easily take over a second for each keystroke to process. Under the bash shell, you can type the beginning of the command and then press the TAB key to auto-complete the command--which is one reason I was so happy to find an NT port of bash. I'm pleased to report that the bash shell works well indeed under a couple of different Telnet clients connecting to my NT box (using the GoodTech Telnet server, which is a very slow server--even on my local intranet).
Cursing My Own Goodie
While doing research for this column, I ran into a problem with Telneting into a remote NT box. I wanted to selectively delete backup files from a source directory before I transferred the data files to my local box. On 95/98, this isn't a big deal--you can use the deltree command, as in:
deltree *.bak /s
However, NT doesn't provide the deltree command. And when I simply copied the program from 95 to NT, it didn't work correctly. So I wanted a tool that I could use to recursively execute the DEL command. While I was at it, I created a simple tool that I can use to recursively execute any command. For your pleasure and entertainment, I've made this program available. It's called recurse and it runs as follows:
recurse [-s startdir] [-e q] <cmd>
The -s option allows you to specify the starting directory (the current directory by default). The -e option tells recurse to quit if an error occurs when running the command inside a directory. (Note that this applies only if the internal call to popen fails--I haven't seen a situation yet where this occurs, even when the spawned shell command reports an error message.) The -q command indicates that you don't want any command output to display to standard output. It outputs messages to standard out, so it's easy to redirect the output to a file or to pipe the output to another program (such as less).
Admittedly, having the bash shell for NT mostly precludes my immediate need for this utility. But it's still a nice thing to have and it was fun to program. Recurse compiles and runs on the following platforms:
95/98/NT--Pre-compiled binary included
Solaris--I used the GNU C++ compiler, as in the following:
g++ -Wall o recurse Main.cpp
HP--I used the CC (native HP C++ compiler), as in:
CC +a1 o recurse Main.cpp
AIX--I used the xlC (IBM C++ compiler for AIX), as in:
xlC o recurse Main.cpp
You can find a zip file that contains the source code, Visual C++ project files, and Windows precompiled binary on the magazine Web page for this issue.
Coming Up Next Time
Now that I've started the ball rolling, I'd like very much to start a "reader exchange" of interesting software utilities. While, of course, I'm interested in additional software reviews, what would be better is to have readers submit interesting utilities that they've written themselves. If you have a slick shell script or a great program you've written, send it in (compressed in gzip or WinZIP format, please!) and share it with the world. We barely scratched the surface on the subject of good UNIX tools for NT, and we can do more columns on it. Hopefully, the ideas submitted to the reader exchange will enable me to focus in on the critical tools you need to get your work done now.
Coming up next time I'll take a look at free CORBA implementations for NT. More and more corporations are using ORB technology to write client-server apps, and some of these ORBs are very expensive. A free ORB may be just the ticket to do some prototyping, since one very nice thing about CORBA is that (like Java and operating systems) by definition it's supposed to insulate the application program from the ORB implementation. So, until then, keep surfing and exploring!