fir3net
PPS-Firenetbanner-780.5x190-30-03-17

BASH - AVG Email Update

This script will email you,

  1. Previous scan results
  2. When the last AV sig update was performed.

Remember to change the username in the variables section prior to running.

#!/bin/bash

#binaries
ls=/bin/ls
tail=/usr/bin/tail
head=/usr/bin/head
awk=/usr/bin/awk
logger=/usr/bin/logger
grep=/bin/grep

#variables
user=admin
logdir="/home/${user}/.avg7/testresults"
log=$(ls -lhtr ${logdir}  | ${tail} -n1 | ${awk} ' { print $8 } ')
logpath="${logdir}/${log}"
main=$(tail -n+7 ${logpath})
upd=$(tail -n1 /opt/grisoft/avg7/var/update/log/avg7upd.log)

#Main

if [ ! -r ${logpath} ]; then
        echo "Error: Unable to read logfile ${logpath}" |  ${logger} -t "AVG EMAIL UPDATE" -p mail.err
        exit 1
else

        #Create the log
cat << EOF > /tmp/avgstat.txt
$main

$upd

EOF
        #Email log
        mail -s "AVG Scan Results" This email address is being protected from spambots. You need JavaScript enabled to view it. < /tmp/avgstat.txt
fi

exit 0      

About the Author

RDonato

R Donato

Rick Donato is the Founder and Chief Editor of Fir3net.com. He currently works as a Principal Network Security Engineer and has a keen interest in automation and the cloud.

You can find Rick on Twitter @f3lix001