]> git.donarmstrong.com Git - bin.git/commitdiff
handle making needs ham rules and kill off output
authorDon Armstrong <don@donarmstrong.com>
Thu, 20 Feb 2014 00:13:08 +0000 (16:13 -0800)
committerDon Armstrong <don@donarmstrong.com>
Thu, 20 Feb 2014 00:13:08 +0000 (16:13 -0800)
learn_from_spam

index 4cacf66433e89567c2cae78d2eefc5be537fb572..d061e45a72f64a768a92e8206a78b8aa270c0484 100755 (executable)
@@ -12,18 +12,22 @@ SPAM_CHECK="spamc -c"
 
 if [ "$(basename $0)" = "learn_from_spam" ]; then
     for file in "$@"; do
-        $SPAM_REPORT < "$file" >/dev/null;
-        formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin -R >/dev/null;
+        $SPAM_REPORT < "$file" >/dev/null 2>&1;
+        formail -c < "$file" | grep -e '^From ' -e 'From: ' | spamassassin -R >/dev/null 2>&1;
         # check to see if it's still spam
-        if ! spamc -c < "$file" >/dev/null; then
+        if ! $SPAM_CHECK < "$file" >/dev/null 2>&1; then
             # this message is still not spam; may need custom rules
-            spamc "$file" > ~/Maildir/spam/needs_rules/cur/"$(basename "$file")";
+            spamc "$file" > ~/Maildir/spam/needs_rules/cur/"$(basename "$file")" 2>/dev/null;
         fi;
     done;
 elif [ "$(basename $0)" = "learn_from_ham" ]; then
     for file in "$@"; do
-        $HAM_REPORT < "$file" >/dev/null;
-        formail -c < "$file" |grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: '|spamassassin -W>/dev/null;
+        $HAM_REPORT < "$file" >/dev/null 2>&1;
+        formail -c < "$file" |grep -e '^From ' -e 'From: ' -e 'To: ' -e 'Cc: '|spamassassin -W >/dev/null 2>&1;
+        if $SPAM_CHECK < "$file" >/dev/null 2>&1; then
+            mkdir -p ~/Maildir/spam/needs_ham_rules/cur;
+            spamc "$file" > ~/Maildir/spam/needs_ham_rules/cur/"$(basename "$file")" 2>/dev/null;
+        fi;
     done;
 else
     "Called in a way this script cannot recognize";