#!/bin/sh # ~/bin/.sh/grepspam # Identifies which phrase to remove from $phrases. # Analyses a non spam mail $1, usually in ~/mail/spam/phrases/ # to find which phrase[s] in $phrases caused procmail to put # a non spam mail in the spam directory. innocent=$1 phrases="$HOME/.DOTS/.procmailrc.spam_shrunk" # phrases="$phrases $HOME/.DOTS/.procmailrc.domains.src" # .procmailrc.domains.src no longer added, as no longer processed into # .procmailrc.spam.inc by ~jhs/public_html/dots/Makefile if [ "$innocent.x" = ".x" ]; then echo "Error. Specify a mail file to scan EG ~/mail/spam/phrases/1" exit 1 fi # if .... JJLATER $innocent not rooted path # pre-pend ~/mail/spam/phrases/ to $innocent # fi if [ \! -r $innocent ]; then echo "Error. Cannot read mail file: $innocent" exit 1 fi for i in $phrases ; do if [ \! -r $i ]; then echo "Error. Cannot read phrases or domains file: $i" exit 1 fi done cat $phrases > $HOME/tmp/grepspam.$$.tmp IFS=' ' export IFS (cd $HOME/public_html/dots ; make grepspam_hook ) > /dev/null for i in `cat $HOME/tmp/grepspam.$$.tmp` ; do # Show lines in mail matching phrase. # grep -i \"$i\" $innocent" # Show spam phrase to delete from $phrases # uncomment next line only if debugging a wrongly syntaxed phrase # echo "Looking for: $i" # grep -q -i "$i" $innocent && echo "Phrase: $i" # If a spam phrases starts with minus, ie '-', # then error report: # grep: invalid option -- # Usage: grep [OPTION]... PATTERN [FILE]... # Try `grep --help' for more information. # brackets.c balance '` grep -q -i "$i" $innocent && echo "Phrase: $i" done rm $HOME/tmp/grepspam.$$.tmp