Hi All,
Attempting to write my first shell script. Getting an error telling me on line "echo Started back up on `date` >> /db2_backup/timer.txt" my script can't create the file. I'm also getting an unmatched "if". But I think there is something else going on.
Can one of you gurus take a quick look and give any pointers/suggestions. Would be most appreciated.
echo Started back up on `date` >> /db2_backup/timer.txt
#set -x
dbname=campmor5
if [ "$dbname" = "" ] then
echo "Usage : " $0 "<dbname>"
exit
endif
listcmd="db2 list applications for database $dbname"
while true do
$listcmd
if [ $? -eq 2 ] then
db2 deactivate database $dbname
exit
endif
$listcmd | tail +5 | nawk '{print $3}' | while read applid
do
if [ "$applid" != "" ] then
db2 "force application($applid)"
endif
#done
#Snoozing for 5 seconds...
sleep 5
#Backing up DB...
db2 backup database campmor5 to /export/home/db2inst1/db2_backups
##SSH file to George..
rsync -a -e ssh -v /export/home/db2inst1/db2_backup db2inst1@enolagay:/export/home/db2inst1/db2_backup
#Checking for successful file transfer...
if ! rsync -a -e ssh -v /export/home/db2inst1/db2_backup db2inst1@enolagay:/export/home/db2inst1/db2_backup then
echo "CAMPMOR DATABASE BACKUP FAILED" >> /db2_backup/timer.txt
print "CAMPMOR DATABASE BACK UP FAILED"
print "CHECK /EXPORT/HOME/DB2INST1/BACKUPCAMPMOR FOR BACKUP EXISTENCE."
exit 1
endif
echo Back up completed on `date` >> /db2_backup/timer.txt
echo --------------------------------------------------- >> /db2_backup/timer.txt
exit
TIA,
T
Attempting to write my first shell script. Getting an error telling me on line "echo Started back up on `date` >> /db2_backup/timer.txt" my script can't create the file. I'm also getting an unmatched "if". But I think there is something else going on.
Can one of you gurus take a quick look and give any pointers/suggestions. Would be most appreciated.
echo Started back up on `date` >> /db2_backup/timer.txt
#set -x
dbname=campmor5
if [ "$dbname" = "" ] then
echo "Usage : " $0 "<dbname>"
exit
endif
listcmd="db2 list applications for database $dbname"
while true do
$listcmd
if [ $? -eq 2 ] then
db2 deactivate database $dbname
exit
endif
$listcmd | tail +5 | nawk '{print $3}' | while read applid
do
if [ "$applid" != "" ] then
db2 "force application($applid)"
endif
#done
#Snoozing for 5 seconds...
sleep 5
#Backing up DB...
db2 backup database campmor5 to /export/home/db2inst1/db2_backups
##SSH file to George..
rsync -a -e ssh -v /export/home/db2inst1/db2_backup db2inst1@enolagay:/export/home/db2inst1/db2_backup
#Checking for successful file transfer...
if ! rsync -a -e ssh -v /export/home/db2inst1/db2_backup db2inst1@enolagay:/export/home/db2inst1/db2_backup then
echo "CAMPMOR DATABASE BACKUP FAILED" >> /db2_backup/timer.txt
print "CAMPMOR DATABASE BACK UP FAILED"
print "CHECK /EXPORT/HOME/DB2INST1/BACKUPCAMPMOR FOR BACKUP EXISTENCE."
exit 1
endif
echo Back up completed on `date` >> /db2_backup/timer.txt
echo --------------------------------------------------- >> /db2_backup/timer.txt
exit
TIA,
T