oreilly.comSafari Books Online.Conferences.


System Administration with ooRexx

by Howard Fosdick and Jon Wolfers

Do you support Windows servers? In any environment where many hands touch the servers, you'll nearly always find wasted space. Leftover .zip and .cab files, obsolete backups and archives, and redundant copies of large files all consume tons of space. Unless you've been diligent in keeping the servers clean, you'll save gigabytes if you identify and remove a couple dozen of the largest obsolete files. Removing these files also speeds up disk backups.

Windows client machines present the same opportunity. Large media files--audio, video, pictures, and images--consume space like candy. Eliminating unneeded ones reclaims that space.

You need a utility to help identify and remove obsolete large files. This article presents a simple script that scans through a disk drive or directory tree, presents a list of the largest files, and lets you delete those you select.

Just for fun, we've written the script in the free Open Object Rexx language. This gives you a chance to explore a scripting language you might not be familiar with while coding a practical utility. The language is easy to learn and use, so you'll be able to read the script and get a feel for it from this example.

Open Object Rexx

Rexx, invented at IBM around 1980, was one of the first scripting languages. It employs a whole range of techniques to combine two language goals that normally conflict: ease of use and power.

Rexx's ease of use led to its role as the bundled scripting language of the Amiga OS and OS/2. Its power awarded it the same role on the three major mainframe operating systems--OS, VM, and VSE. Today there are several free Rexx interpreters that run on every machine, from handhelds and desktops to servers and mainframes. We discussed traditional, procedural Rexx in Rexx: Power Through Simplicity.

Related Reading

Classic Shell Scripting
Hidden Commands that Unlock the Power of Unix
By Arnold Robbins, Nelson H.F. Beebe

Open Object Rexx is a 100 percent upwardly compatible superset of "classic" procedural Rexx. Any Rexx script runs under ooRexx. ooRexx adds full object orientation. This includes classes; messaging; objects; single and multiple inheritance; data hiding and encapsulation; operator overloading and polymorphism; and a large, powerful class library.

IBM developed Open Object Rexx ten years ago and distributed it as IBM Object REXX. It is experiencing renewed interest today because IBM open-sourced the product and turned it over to the Rexx Language Association. The new ooRexx racked up a quick 24,000 downloads after its unveiling at SourceForge last March, placing it among the top 3 percent of SourceForge downloads at that time. ooRexx runs under Windows, Linux, and Unix. (Our script runs on Windows and uses a Windows GUI.)

Installation and Setup

To get started, access the ooRexx homepage. Here you'll find background information and a link to the SourceForge page from which you download ooRexx and its documentation. Download the .exe product file for Windows. Just click on the file after downloading it to install the product.

The product includes full documentation, a set of six PDF files that reside in the doc/ folder in the install directory. It also installs a samples folder that contains several dozen example ooRexx scripts. For the Windows platform, these scripts demonstrate Windows integration features including ActiveX, Object Linking and Embedding (OLE), Windows Script Host (WSH), Active Directory Services Interfaces (ADSI), and Windows Management Instrumentation (WMI).

Installing ooRexx establishes a Windows file association between files with the .rex extension and the ooRexx interpreter, so you can just double-click on a script to run it. You can also run scripts from the Windows command line. Of course, object-oriented scripts must be able to access their class libraries. ooRexx concatenates its standard class library directory to your Windows PATH variable.

Before you can run our example script to identify and delete large files, you must also download a free class library from the web site Sahananda's Rexx tools (or you can download this file from a link at the end of this article). Download the BrowseForFolder class (the file named folderBrowse.cls) from the web site and place it in the ooRexx class library folder indicated by the Windows PATH variable. This is the root of the directory tree where you installed ooRexx.

When you run our example script to identify and delete large files, it displays a panel as shown in Figure 1. This allows you to select the disk drive or directory for which you want to see the largest files.

Figure 1
Figure 1. Selecting a directory

After you select the drive or directory to work with, the program displays a sorted list of the largest files on the drive or in the directory. You can select and delete as many individual files as you like. Figure 2 shows a user preparing to delete the highlighted duplicate file. Pressing the Leave button ends the script.

Figure 2
Figure 2. Preparing to delete a duplicate file

Pages: 1, 2, 3

Next Pagearrow

Sponsored by: