The Section Building MIME Drafts Automatically has an overview of automhn. Here is the automhn 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. Tt probably doesn't need to be configured--unless your system doesn't have the MH commands in its search path, when you'll want to add a full pathname on the mhn command at the end.
The main while loop reads the draft file line by line. If a line starts with a hash sign (#), the unless tests the line to see if it looks like a valid mhn directive. (Here's a table of mhn directives.) If it doesn't look like a directive, the script adds an extra hash sign to the start of the line; mhn will strip off the extra hash sign when it processes the draft. Each line of the input draft is added to the $outtext variable. At the end of the script, if any lines were modified, the script opens the draft file (named in the first command-line argument) and writes $outtext to it. Finally, the script execs mhn to process the draft, if needed. (If this script will only be run under nmh, you could change this last line to run mhbuild instead.)
This file first appeared in the updated online edition of the book MH & nmh: Email for Users & Programmers, by Jerry Peek. It is freely available; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. For more information, see COPYING.
Copyright © 1997 Jerry Peek
Last modified: 2006-05-31 15:13:43 -0700