From owner-freebsd-questions@FreeBSD.ORG Sun Jun 14 20:07:27 2015 Return-Path: Delivered-To: freebsd-questions@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C10C79A for ; Sun, 14 Jun 2015 20:07:27 +0000 (UTC) (envelope-from listmgr@antennex.com) Received: from BAY004-OMC2S9.hotmail.com (bay004-omc2s9.hotmail.com [65.54.190.84]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (Client CN "*.outlook.com", Issuer "MSIT Machine Auth CA 2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id E8A5AC81 for ; Sun, 14 Jun 2015 20:07:26 +0000 (UTC) (envelope-from listmgr@antennex.com) Received: from BAY404-EAS148 ([65.54.190.123]) by BAY004-OMC2S9.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.22751); Sun, 14 Jun 2015 13:07:20 -0700 X-TMN: [fHlgj1WIakx8tMGOTDK2NHOIFfWnM3AtC4YfQlk8SIs=] X-Originating-Email: [listmgr@antennex.com] Message-ID: From: "Lt. Commander" To: "'jd1008'" , References: , , , <557B8484.9060405@gmail.com> <557C6DED.9070105@gmail.com> In-Reply-To: <557C6DED.9070105@gmail.com> Subject: RE: Script question Date: Sun, 14 Jun 2015 15:07:18 -0500 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Mailer: Microsoft Outlook 15.0 thread-index: AQABAgME0X1Dm5rl1ITbGRHvuqm5ZwDmqqb4AImG+awAOb+0/QChWiN0ACr4FWoAANHiZ6E3/NGA Content-Language: en-us X-OriginalArrivalTime: 14 Jun 2015 20:07:20.0979 (UTC) FILETIME=[B8A8AE30:01D0A6DD] X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 14 Jun 2015 20:07:27 -0000 On 06/13/2015 06:58 AM, Lt. Commander wrote: >> Date: Fri, 12 Jun 2015 19:16:52 -0600 >> From: jd1008@gmail.com >> To: freebsd-questions@freebsd.org >> Subject: Re: Script question > Here is a short shell script: > > #!/bin/sh > > while read line; do > score=`echo $line | grep ' score=.. '` scoreValue=`echo $score | sed > -e 's/score=//' -e 's/ *//'` address=`echo $line | grep > 'client_addr=[0-9]*\.[0-9]*\.[0-9]*.[0-9]* '` IP=`echo $address | sed > 's/client_addr=//'` > > if [ $scoreValue -ge 12 ]; then > echo $score > echo $IP > echo ==================== > fi > done < your-log-file-name> > some-file-to-use-to-construct-the-spamassasin filter > > ---------------------------------------- >> Date: Fri, 12 Jun 2015 19:16:52 -0600 >> From: jd1008@gmail.com >> To: freebsd-questions@freebsd.org >> Subject: Re: Script question >> > That's a very interesting shell script and will give it a try. > > But, does the script only pickup spam with a "12" tag level or does it pick up 12 and above which is what I need? (sorry, my scripting is not strong). > > Jason The boolean -ge in the if test. Greater than or equal to So it grabs all 12 or greater values. --------------------------------------------------------------- I understood the -ge had some purpose but FBSD didn't like it, at least where it was placed, so that script didn't work. However, later that night, I took a different approach and patched together a script that gives me what I wanted. For the list here it is if you use a spam filter that consistently tags spam that can be latched onto: I know it's ugly..... but places a list of the IPs in a file plus sends me a message with the same list. The file can be pumped into the /etc/mail/access file to block those IPs. #!/bin/sh cd /var/log grep -i spam=YES maillog > spam.tmp && \ awk '{print $11}' spam.tmp | sort | uniq > spam-hi && \ sed -e 's/^.*=//' spam-hi > spam-ip && \ cat spam-ip >> /usr/samba/mail/envelope cat spam-ip | mail -s "SPAM IPs...." us.navy@outlook.com