MH & nmh: Email for Users & Programmers

May, 2006

Explanation of rcvsearch

The Section Regular Expression Matching with rcvsearch has an overview of rcvsearch. Here is the rcvsearch script (you might want to open it in a separate browser window). To install it, see the Section Programs in This Book's Archive.

The script is simple; it doesn't need to be configured. It's designed to be run from a .maildelivery file. It reads a complete email message (header and body, separated by a blank line) from its standard input into a temporary file. If an egrep search using the first command-line argument ($1) fails, the script fails and returns an exit status of 20. Otherwise, the script runs the program named in the second command-line argument ($2) and passes any other command-line arguments to that program. When that program finishes, its exit status is passed to slocal; a zero status means that slocal can consider the message "delivered."

Of course, you can adapt the program to do different searches. If you want to do a series of specific searches, for example, you could give rcvsearch multiple names, one for each search; that could avoid passing messy command-line arguments.