-->

Previous | Table of Contents | Next

Page 450

Python

Python can be of special interest to Red Hat Linux users. Python is object-oriented, modern, clean, portable, and particularly easy to maintain. If you are a full-time system administrator looking for a scripting language that will grow with you, consider Python. The official home page for Python is http://www.python.org.

Emacs

Emacs is one of the most polarizing lightning rods for religious controversy among computer users. Emacs has many intelligent and zealous users who believe it the ideal platform for all automation efforts. Its devotees have developed what was originally a screen editor into a tool with capabilities to manage newsgroup discussion, Web browsing, application development, general-purpose scripting, and much more. For the purposes of this chapter, what you need to know about Emacs is as follows:

Even if the "weight" of Emacs (it's slow on startup and seems to require quite a bit of education and configuration) sways you against its daily use, keep it in mind as a paragon of how sophisticated programming makes common operations more efficient.

procmail

Computer use has exploded in the Internet era. The most indispensable, most used Internet function is e-mail. Can e-mail be automated?

Yes, of course, and it's perhaps the single best return on your invested time to do so. Along with aliases, distribution lists, startup configurations, and the plethora of mail agents or clients with their feature sets, you'll want to learn about procmail. Suppose that you receive a hundred messages a day, that a fifth of them can be handled completely automatically, and that it takes at least three seconds of your time to process a single piece of e-mail; those are conservative estimates, from the experience of the computer workers I know. A bit of procmail automation will save you at least a minute a day, or six hours a year. Even conservative estimates make it clear that an hour of setting up procmail pays for itself many times over.

Along with the man procmail* pages, serious study of procmail starts with the page http://www.faqs.org/faqs/mail/filtering-faq, Nancy McGough's "Filtering Mail FAQ." This gives detailed installation and debugging directions. To supplement it, I've launched the page http://starbase.neosoft.com/~claird/comp.mail.misc/procmail.html to keep you updated

Page 451

on the latest procmail news. Because your Red Hat Linux machine will almost certainly have a correctly configured procmail, you can immediately begin to program your personal use of it. As a first experiment, create exactly these files: ~/.procmailrc, with contents


VERBOSE=on

MAILDIR=$HOME/mail

PMDIR=$HOME/.procmail

LOGFILE=$PMDIR/log

INCLUDERC=$PMDIR/rc.testing



~/.procmail/rc.testing, holding



:0:

* ^Subject:.*HOT

SPAM.HOT

and ~/.forward, with


"|IFS=' ` && exec /usr/local/bin/procmail -f || exit 75 #YOUR_EMAIL_NAME"

After you create these three, set necessary permissions with the following:


chmod 644 ~/.forward

chmod a+x ~/.

Now exercise your filter with the following:


echo "This is the first message." | mail -s "Example of HOT SPAM." YOUR_EMAIL_NAME

echo "This is the second message." | mail -s "Desired message." YOUR_EMAIL_NAME

What you now see in your mailbox is only one new item, the one with the subject Desired message. You also have a new file in your home directory, SPAM.HOT, holding ... the first message.

procmail is a robust, flexible utility you can program to achieve even more useful automations than this. When you gain familiarity with it, it will become natural to construct rules that, for example, automatically discard obvious spam, sort incoming mailing-list traffic, and perhaps even implement pager forwarding, remote system monitoring, or FAQ response. This can save you considerable time each day.

calendar

calendar is quite specialized, easy to use, and, because it matches a real-world need particularly well, very useful. calendar takes responsibility for sending messages to your screen to remind you of events or responsibilities. You can download calendar from ftp://ftp.redhat.com/pub/contrib/i386, file calendar-8.4-3.i386.rpm. Experiment with calendar by creating a local file called calendar (the command and the specification file have the same name, in general) with the following contents:


#include "/usr/lib/gcal-lib/calendar.holid"

Monday\tTake out trash.

Page 452


Tuesday\tFeed dolphin.

Wednesday\tRe-synchronize orgone collector.

Thursday\tKaryotype produce from refrigerator.

Friday\tTake out trash.

Saturday\tPractice polo.

Sunday\tClimb Matterhorn.

Run calendar. You'll see a few historical events with current anniversaries, and your own applicable daily chores. Three aspects of calendar give it dramatic power:


#include "/some/centrally/maintained/directory/calendar.bigboss"

#include "/some/centrally/maintained/directory/calendar.cafetaria"



/* My own stuff follows ... */

the first reminders calendar gives you will be those for the company president and the lunch-time menu, with your personal events after.

Although calendar does a small job, it does it efficiently. Consider whether its capability to focus attention on the upcoming days' priorities matches your needs.

Internal Scripts

One more element of the automation attitude is to be on the lookout for opportunities within every application you use. Scripting has become a pervasive theme, and almost all common applications have at least a rudimentary macro or scripting capability. IRC users know about bots, Web browsers typically expose at least a couple of scripting interfaces, all modern PPP clients are scriptable, and even such venerable tools as vi and ftp have configuration, shortcut, and macro capabilities that enormously magnify productivity. If you use a tool regularly, take a few minutes to reread its presentation in this volume; chances are, you'll come up with a way to make your work easier and more effective.

Concluding Challenge for an Automater—Explaining Value

You've become knowledgeable and experienced in scripting your computer so that it best serves you. You know how to improve your skills in script-writing. You've practiced different approaches enough to know how to solve problems efficiently. The final challenge in your automation career is this: How do you explain how good you have become?

Previous | Table of Contents | Next