#!/bin/sh
#########################################
# MailAdmin.sh
# blueantelope
# blueantelope@
# 2007-12-07
# Write on Office
#--------------------------------------------------
# The shell uses send mail to Administrator
# to report Client backup status. It uses bsmtp
# maintly at 17:00 daily.
#--------------------------------------------------
# LocalEmail : local mail virutal account, mail from
# AdminEmail : Administrator' account, send to
LocalEmail="[email protected]"
AdminEmail="[email protected]"
logdir="/var/log/IncrementDTP/"
# First element in thr array is length of the array
logfile=("5" "user1.log" "user2.log" "user3.log" "user4.log" "user5.log")
#echo $logfile
filecount=`expr ${logfile[0]}`
initcount=1
#echo $filecount
while [ $initcount -le $filecount ]
do
userlogfile=$logdir${logfile[$initcount]}
if [ -f $userlogfile ]; then
sed -n '$p' $userlogfile >> /tmp/mailstatus # Filter the log file to obtain stat
us of backup now in the last line
echo "" >> /tmp/mailstatus
else
echo "${logfile[$initcount]} is not exist" >> /tmp/mailstatus
echo "" >> /tmp/mailstatus
fi
initcount=`expr $initcount + 1`
done
# -f set the From
# -h smtp server
# -s title
# /tmp/mailstatus : mail content
bsmtp -f $LocalEmail -h mailserver.com -s "Incremnet status for every Clinet from ClientBackup" $AdminEmail
< /tmp/mailstatus
rm -rf /tmp/mailstatus
|