You may think of PERL as something for Unix gurus, but wise Windows administrators can also benefit from this powerful scripting language.

PERL’s Hidden Treasures

You may think of PERL as something for Unix gurus, but wise Windows administrators can also benefit from this powerful scripting language.

So just what is PERL, and where did it come from? PERL stands for Practical Extraction and Report Language. Its original value was for sorting through and making sense of large amounts of text files. But, over time, it has expanded and become a powerful tool for network administration, including Windows 2000 networks. Unix administrators have long known the value of PERL as a time-saving and powerful scripting language, and many of today’s Web sites have PERL scripts running a variety of processes in the background. Its versatility and usefulness make it equally valuable in the Windows world too.

But when to use PERL? For a simple one-time task, like adding a single user, PERL won’t be a time-saver. However, when you find yourself having to perform the same task over and over again, or you have to complete a task on hundreds or thousands of machines, PERL becomes a powerful ally.

You can find PERL in either the Win2K Server or Win2K Professional Resource Kits. Along with the source code, the Resource Kits contain more than 60 sample PERL scripts. The number and variety of samples alone makes the Kit a worthwhile purchase. As an alternative, you can download the latest source code free from www.activestate.com.

More PERLs

If you’d like to look deeper into PERL, the place to start is www.activestate.com. Here you’ll find all the latest versions of PERL, along with the newest beta release. Best of all, you’ll find these versions in Win2K .msi formats. The site also has excellent documentation in HTML format.

Another place to point your browser is www.perl.com and www.perl.org. While you’ll find that both sites contain a vast amount of information on PERL, most of it is geared toward Unix administrators, not NT/2000 types.

Finally, I can’t say enough good things about the books from Dave Roth. He currently has two: Win32 Perl Programming: The Standard Extensions and Win32 Perl Scripting: The Administrator’s Handbook (both from New Riders Publishing). The books offer easy-to-follow explanations and hundreds of examples. Using his book and script examples has saved me countless hours on administrative tasks.

—Michael Feuda

Let’s focus on the sample PERL scripts you’ll find in the Win2K Resource Kits. These PERL scripts can be used to streamline tasks for DNS, User and Group management, disk quotas, event logs, services and so on. PERL can even be used as a powerful option for implementing login scripts.

Rather than actually look at the guts of a PERL script (which can be very lengthy), let’s examine a few practical examples from the sample scripts available with the Resource Kits.

Say you’d like to monitor disk usage for users or machines remotely. As part of that process, you periodically want to receive a quick summary of disk usage on your network. The PERL script you’d use to check this is diskusage.pl. As with all the PERL scripts, you’ll launch a command window (a.k.a. good ol’ DOS prompt) to look at the syntax of these PERL scripts. After issuing the Start | Run | cmd.exe command, type in “diskusage.pl -?” to get detailed help choices. You’ll get the proper syntax for the script, a description of the script’s function, a detailed breakdown of parameter options, some notes particular to this script, and even some samples. Among all the sample PERL scripts, you’ll find the same consistency and format.

Another situation many Win2K administrators find themselves is needing to query the status of event logs on both local and remote machines. For this task, use the eventlog.pl script. This one script can clear event logs, change settings, export and so on. The power of the PERL script gives you the ability to run this against a large number of machines or even have it run as a scheduled task.

One more example is the serviceconfig.pl script. This script lets you take a look at or change any options for Win2K services. Suppose you wanted to change a service account password or shut down a particular service on hundreds of machines. You could perform this task one machine at a time or use this PERL script and run it against all of the machines at once. It’s a pretty easy choice, isn’t it?

The diskusage.pl script shows how well the options are documented. Use this script to query file or directory information easily from remote machines. (Click image to view larger version.)

Check out the powerful scripting power of PERL and the well-written scripts from the Resource Kits. You’ll see how efficiently and quickly they run and how they can help you become a better Win2K administrator.

About the Author

Michael Feuda, MCSE, NNCDS, is an independent writer. He has worked with Microsoft products since the days of LAN Manager.

comments powered by Disqus
Most   Popular

Upcoming Training Events

0 AM
Live! 360 Orlando
November 17-22, 2024
TechMentor @ Microsoft HQ
August 11-15, 2025