Mailing List CGatePro@mail.stalker.com Message #97216
From: John Kougoulos <koug@intracom.gr>
Subject: Re: /usr/bin/mail binary replacement of CGP
Date: Fri, 6 Feb 2009 16:24:54 +0200 (GTB Standard Time)
To: CommuniGate Pro Discussions <CGatePro@mail.stalker.com>
Hello,

you could also use something like:

   grep "koko" myfile && mail -s "koko found" me@example.com

Regards,
John

On Fri, 6 Feb 2009, Stefan Seiz wrote:

On 06.02.2009 13:38 Uhr "Stefan Seiz" <TalkLists@index-s.de> wrote:

I'd also be open to any hinst to a workaround as long as it doesn't involve
the creation of a file (which could then be checked for content before
mailing it).

Here's an example srcipt i call through cron every night, where the -E
switch would come in realy handy:

/usr/bin/grep " incorrect password" /var/CommuniGate/SystemLogs/`date
+%Y-%m-%d.log` | /usr/bin/mail -E -s "Email Hacking Attempts" me@example.com

Thanks!

Asnwering my own Question.

So i simply wrote a "proxy script" to mail which only calls mail if it
receives anything on stdin. Hope this will be useful to others as well:

#!/bin/sh

read mystdin
if [ "$mystdin" ] ; then
   echo $mystdin | /usr/bin/mail "$@"
fi





Example usage (if the script would be called mailonlybody):

grep -i "shithappened" SystemLogs/`date +%Y-%m-%d.log` | mailonlybody -s
"shit" you@example.com

You can call this script exactly as you'd call CGP's /usr/bin/mail
replacement, only this one won't trigger an email if you don't pass anything
to it on standard in.

--
Stefan Seiz <http://www.StefanSeiz.com>
Spamto: <bin@imd.net>



#############################################################
This message is sent to you because you are subscribed to
 the mailing list <CGatePro@mail.stalker.com>.
To unsubscribe, E-mail to: <CGatePro-off@mail.stalker.com>
To switch to the DIGEST mode, E-mail to <CGatePro-digest@mail.stalker.com>
To switch to the INDEX mode, E-mail to <CGatePro-index@mail.stalker.com>
Send administrative queries to  <CGatePro-request@mail.stalker.com>

Subscribe (FEED) Subscribe (DIGEST) Subscribe (INDEX) Unsubscribe Mail to Listmaster