Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

If Then problem

Status
Not open for further replies.

mbach

Technical User
Dec 12, 2000
24
0
0
US
All,
Below is a script I wrote which extracts the names of servers which had backups that were partially successful. At the bottom of my script I email a file which usually contains a list of servers. When there are no partially successful backups, the email is blank. I want to modify the script so that if there are no partially successful backups the email will say..." No error 1 backups today"
I guess I need an if then logic statement.
Thanks for any suggestions!!!
Mike
Here is the script....
#!/usr/bin/ksh
#This script will create a file listing all NT servers which had error 1
#failures for the last 12 hours and also list the files which failed to be
#backed up for each server.
DATE=`date +%D`
BPERROR=/usr/openv/netbackup/bin/admincmd/bperror
#
#Let's get all the servers which failed with error 1
#
$BPERROR -backstat -hoursago 12|grep partially|awk '{print $9}' | sort -u > /tmp/servers
#
#Now we will do a for i loop to find out which files failed on each server
#
for server in `cat /tmp/servers`
do
echo $server>>/tmp/servers1
$BPERROR -problems | grep $server |/usr/bin/awk '{i=index($0,"file:");j=index($0,$NF);x=j+5;if(i!=0)print substr($0,i,x);}'|cut -c,7-200|awk -F\( '{print $1}'|sort -u>>/tmp/servers1
done
cat /tmp/servers1 |/usr/bin/mailx -s "Redmond NT error 1 failures at 5am ct $DATE" someone_who_cares@somewhere.com
rm /tmp/servers
rm /tmp/servers1
 
Just before you mail
Code:
if [ ! -f /tmp/servers1 ]; then
  echo No error 1 backups today > /tmp/servers1
fi
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top