Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 15 Jun 2015 02:27:35 +0200
From:      Patrick Hess <patrickhess@gmx.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: Script question
Message-ID:  <2609852.Pc7nSdcYla@desk8.phess.net>
In-Reply-To: <20150615015516.b3ea7633.freebsd@edvax.de>
References:  <BAY182-W89C2924F4BDF0D2BD3810DF4BB0@phx.gbl> <BAY404-EAS148D4B304BB066F07E84004CCB90@phx.gbl> <20150615015516.b3ea7633.freebsd@edvax.de>

next in thread | previous in thread | raw e-mail | index | archive | help
Polytropon wrote:
> Or if you want to omit the grep call:
> 
> awk '/spam=YES/ {print $11}' /var/log/maillog | sort | uniq | sed -e 's/^.*=//' > /tmp/spam-ip.txt
> 
> And then continue:
> 
> cat /tmp/spam-ip.txt >> /usr/samba/mail/envelope
> cat /tmp/spam-ip.txt | mail -s "SPAM IPs...." us.navy@outlook.com
> 
> Finally, you can easily remove /tmp/spam-ip.txt.

You could even take this one step further and eliminate the need for
a temporary file altogether by making use of tee(1):

    awk '/spam=YES/ {print $11}' /var/log/maillog |
    sort |
    uniq |
    sed -e 's/^.*=//' |
    tee -a /usr/samba/mail/envelope |
    mail -s "SPAM IPs...." us.navy@outlook.com

Patrick



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?2609852.Pc7nSdcYla>