C. Paul Ferroni asked,
| :0 h
| FOLDER=| /usr/local/bin/formail -rt -xFrom: | awk -F@ '{print $2}' | awk
-F. '{print $1}'
After inverting the header with -rt there shouldn't be a From: line, so no
wonder you're getting null values for $FOLDER. What I think you want here is
the first element of the site name that's sending you the message. (I find
the Message-Id: header more reliable for that, but your mileage may vary ...
a LOT.)
| :0 c
| | echo "`/usr/local/bin/formail -x From:` (filed to cron - $FOLDER)" |
mail.sh -noise
| I recognize that the formail/awk/awk line generates 3 subshells, and is
| not efficient -- is there a better way to extract the nodename from this line?
First, you should have a PATH assignment early in your .procmailrc that adds
/usr/local/bin to procmail's compiled-in $PATH (if it isn't already there)
rather than needing to spell out the whole route to formail every time you
call it. But anyhow, if you're using a recent enough version of procmail to
have the MATCH facility, this should be far more efficient:
:0 # Extract and save everything after @
* ^From:(_dot_)*(_at_)\/[^.].+
{ SENDINGSITE = $MATCH }
:0A # Extract and save everything up to first period
* SENDINGSITE ?? ^^\/[^.]+
{ FOLDER = $MATCH }
:0Achi
| echo "$SENDINGSITE (filed to cron - $FOLDER)" | mail.sh -noise