Are you Sick of Spam?


I'm definitely sick of spam, those uninvited piles of junk e-mail asking me to browse pornographic Web sites, take part in pyramid investment schemes, or make a million dollars by hassling my friends. I suppose I'm lucky that I'm located some distance from the spam 'action', and so only receive 4 or 5 spam e-mail messages per day. Unfortunately, that's already exceeding my tolerance levels.

There are plenty of spam-removal tools available (see the complete article for details), but I didn't want to spend a lot of time writing filtering rules or setting up configuration files. Instead, I wrote two small Bourne Shell scripts, totalling about a page of code, to do the job. Using the Bourne Shell means that I could take advantage of numerous general-purpose UNIX tools, such as grep, tr, and awk, and many utilities for mailbox manipulation (I've used from, readmsg, and mail).

In the article, I describe my two Shell scripts (new_msgs and spammer) for dealing with spam. One novel feature of spammer is that it examines the text of a message for spam words. These words are specified by the user in mail.spamwds. I also illustrate how easy it is to build other mail utilities with Shell scripts: list_msgs, heads.awk, and checkmail.

I don't explain the basics of Shell scripting, which are dealt with in many excellent books. The classic is The UNIX Programming Environment by Brian Kernighan and Rob Pike, Prentice Hall, 1984. A more recent text, which considers programming with the Bourne, C Shell, and Korn Shells, is A Practical Guide to the UNIX System by Mark Sobell, Benjamin-Cummings, 1995. However, I do present some details on the UNIX mailbox format since this is necessary for understanding certain aspects of my programs.


Back to Web Programming