It could be ...
Just use the -E switch in the mail command:
man -Pcol\ -b mail | grep empty -E Don't send messages with an empty body. #!/bin/bash ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | # Binary grep 'INFECTED|Vulnerable' | # Only get found issues /bin/mail -E -s 'CHROOTKIT Weekly Run ($SERVERNAME)' $EMAIL # Send EMail
or put your check in crontab for automatic processing, for example, once a day:
@daily ( /usr/src/chkrootkit-$VERSION/chkrootkit ) | grep 'INFECTED|Vulnerable'
Cron will send mail if the command issues something.
But after reading this again
If there is no need to forward any part of the mail in the notification, there is no need to use the pipe | .
So you can use the condition as follows:
#!/bin/bash ( /usr/src/chkrootkit-$VERSION/chkrootkit ) |
The -q switch to grep provides peace of mind.
source share