#!/bin/bash
( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary
grep 'INFECTED|Vulnerable' | # Only get found issues
/bin/mail -s 'CHROOTKIT Weekly Run ($SERVERNAME)' $EMAIL # Send EMail
This still sends e-mails even if nothing is found.
What would be a way to only send if something is grepped?
This maybe…
Simply use
-Eswitch in mail command:or place your check in a
crontabfor automatic processing, for ex once a day:Cron will send a mail if command output something.
But, after re-reading this
If there is no need to forward any part of the mail in the alert, there is no need to use the pipe
|.So you could use condition in this way:
The
-qswitch togrepensure to stay quiet.