# Explanation of automhn

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.)