Re: extract header from current message (to pass to shell)?
Hi,
Just to post the solution I've finally adopted, in case anyone comes
across this and wants to cut and paste. Seems to work fine.
I actually now feed two different blacklists locally, because one is a
mailing list that moves a lot faster than the other stuff, so it makes
sense to crop that more often. Incidentally, I don't know what a
reasonable length to crop would be, given that procmail has to process
the recipe (I know I had to bump up LINEBUF). I just guessed.
I realized I need the References and not just the Message-ID if I want
to be able to ignore threads after a few messages have passed, and I
also need "References", not "In-reply-to" in the procmailrc to catch replies
after the
first one (duh, should have looked at Kyle's message more closely).
.muttrc:
folder-hook . 'macro index "I" "<pipe-message>/usr/bin/formail -c -z -x
References -x Message-ID | cut -d\">\" -f1 | tr -d \"<\" >>
~/.mutt/ignore_all<enter><delete-thread>" "ignore thread"'
folder-hook =isomerica/r-help 'macro index "I" "<pipe-message>/usr/bin/formail
-c -z -x References -x Message-ID | cut -d\">\" -f1 | tr -d \"<\" >>
~/.mutt/ignore_r<enter><delete-thread>" "ignore thread"'
Shell script that crops, sets flags, removes duplicates and if
necessary uploads changes to the server
#!/bin/bash
IGNOREFILE=$HOME/.mutt/ignorelist
RIGNORE=$HOME/.mutt/ignore_r
RFLAG=$HOME/.mutt/.ignoreflag_r
ALLIGNORE=$HOME/.mutt/ignore_all
ALLFLAG=$HOME/.mutt/.ignoreflag_all
SERVER=server.name.here
if [ "$RIGNORE" -nt "$RFLAG" ] || [ "$ALLIGNORE" -nt "$ALLFLAG" ]; then
ping -c1 $SERVER > /dev/null 2>&1
if [ $? != 0 ] ; then
exit 0
else
{ rm "$ALLIGNORE" && awk '!x[$0]++' > "$ALLIGNORE"; } < "$ALLIGNORE" ||
exit 1
while [ "$(wc -l $ALLIGNORE | cut -d ' ' -f 1)" -gt 40 ]; do
/bin/sed -i '1d' "$ALLIGNORE"
done
cat "$ALLIGNORE" > "$IGNOREFILE" || exit 1
{ rm "$RIGNORE" && awk '!x[$0]++' > "$RIGNORE"; } < "$RIGNORE" || exit 1
while [ "$(wc -l $RIGNORE | cut -d ' ' -f 1)" -gt 110 ]; do
/bin/sed -i '1d' "$RIGNORE"
done
cat "$RIGNORE" >> "$IGNOREFILE" || exit 1
rsync --times $IGNOREFILE $SERVER:.procmail/ignorelist && touch
"$RFLAG" && touch "$ALLFLAG"
fi
fi
.procmailrc:
IGNORETHREADLIST=cat $HOME/.procmail/ignorelist | tr -d " " | tr "\n" "|" | sed
's/|$//'
:0
* $ ^References:.*($IGNORETHREADLIST).*
*
!(^(To|Cc).*(my|email|adresses).*)
inbox/.ignored-threads/
Thanks again for your help,
m.