Grep output's to my display from within a script.

From: Simon Crowther (scrowthe@msxi-euro.com)
Date: Thu Jun 05 2003 - 07:38:11 EDT


Hi,

I have a script that sidelines spam ID'd by Spamassassin,

It greps for an X-header, and if a match is found, the mail is
redirected to a spamtrap account.

When I test this on the command line, and the sample mail (spam)
matches, output from the grep is sent to my display.

Can someone please remind me how to suppress this, thanks.

below is the script.....

Simon.

#!/bin/sh
#
# This script will move spam to a dedicated account
#

# File locations:
INSPECT_DIR=/var/spool/filter
SENDMAIL="/usr/lib/sendmail -i"
SPAMASSASSIN=/usr/local/bin/spamassassin

# Exit codes from <sysexits.h>
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting
trap "rm -f in.$$ out.$$" 0 1 2 3 15

# Set spam sideline parameters
# ( "X-Spam-Status: No, hits=6.8" = "X-Spam-Level: ******" )
SPAMMAIL=spamassassin@msxi-euro.com
SPAMLIMIT=6

export SPAMMAIL SPAMLIMIT

# start processing
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit
$EX_TEMPFAIL; }

cat > in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

$SPAMASSASSIN -x < in.$$ > out.$$ || { echo Message content rejected;
exit $EX_UNAVAILABLE; }

# Test for X-Spam-Level header 'stars' exeeding the SPAMLIMIT
if
        /usr/bin/grep "^X-Spam-Level: \*\{$SPAMLIMIT,\}" <out.$$ 2>
/dev/null
 then
        $SENDMAIL $SPAMMAIL < out.$$
 else
        $SENDMAIL "$@" < out.$$
fi

exit $?
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers



This archive was generated by hypermail 2.1.7 : Wed Apr 09 2008 - 23:26:32 EDT