Salut, Philip,
On Tue, 26 Aug 2008 10:00:36 +0100, Philip wrote:
> I want a shell script that I can cron. I want this script to do an
> audit-packages and send me an email if there is anything that needs
> patching. The script below works, except that it sends the email even
> if audit-packages returns nothing.
>
> Can anyone improve it? the last two lines should be one line
> thanks, Philip
>
>
> #!/bin/sh
> /usr/pkg/sbin/download-vulnerability-list
> /usr/pkg/sbin/audit-packages > /root/auditpackages.txt
> (echo "Subject: Audit Packages Output";cat
> /root/auditpackages.txt)|/usr/sbin/sendmail me%example.com@localhost
My suggestion would be to have the following /etc/security.local:
=== BEGIN /etc/security.local ===
if [ -x /usr/pkg/sbin/download-vulnerability-list ]; then
/usr/pkg/sbin/download-vulnerability-list 2>&1 > /dev/null
fi
if [ -x /usr/pkg/sbin/audit-packages ]; then
/usr/pkg/sbin/audit-packages
fi
=== END /etc/security.local
Tonnerre
Attachment:
signature.asc
Description: PGP signature