Hello Once Again,
I am putting finishing touches to my script.
Basically, it is functioning now, however, I wanted to additionally an if statement saying if there is no tables to be processed, the script should die, and exit with email saying there is no table to be repaired.
The if statement starts at Line #23.
However it is reporting error:
./spx_repair_sfgi_3.sh[23]: [!: not found
I am putting finishing touches to my script.
Basically, it is functioning now, however, I wanted to additionally an if statement saying if there is no tables to be processed, the script should die, and exit with email saying there is no table to be repaired.
The if statement starts at Line #23.
However it is reporting error:
./spx_repair_sfgi_3.sh[23]: [!: not found
Code:
#!/bin/ksh
dbname=sfgi
export ORACLE_SID=$dbname
export ORACLE_HOME=/orahome/app/oracle/product/10.2.05/dbq413
. /usr/sislocal/$dbname/to$dbname
#log into database
sqlplus -s splex/password << EOF
set pagesize 0
set linesize 4000
set feedback off
set trimspool on
spool rowcount.txt;
select source_name from splex.count_match_vw;
spool off;
EOF
#Begin if file empty, die and exit.
if [! -f "$rowcount.txt"]; then
mailx -s "Comparing the tables in Shareplex SFGI<->CTXI Environment produces no mismatch." myemail@email.com<< END
END
else
mailx -s "The following tables have rowcount mismatch in Shareplex SFGI<->CTXI Environments" myemail@email.com<< END
`cat rowcount.txt`
END
# Create the file extensions and files to be used:
basename=spsfgi
now=`date '+%y-%m-%d_%H-%M-%S'`
repair_dir=/orahome/app/oracle/home
repairfile=$repair_dir/$basename.$now.sh
logfile=$repair_dir/$basename.$now.log
resultfile=$repair_dir/$basename.$now.out
#remove from table names.
#`sed 's/"//g'rowcount.txt>tblname.tx`
#loop through tblname.txt
for tblname in `cat /orahome/app/oracle/home/rowcount.txt`
do
#set shareplex environment
cd $repair_dir
LOG_FILE=$repair_dir/rc_loop_rep_our.log
. ./spenv_splex_Port#_sfgi.sh
#export SP_SYS_PRODDIR=/orahome/app/SharePlex/10g/prod
#export SP_SYS_VARDIR=/orahome/app/SharePlex/10g/varsplex_Port#_sfgi
#export SP_COP_UPORT=splex_Port#
#export SP_COP_TPORT=splex_Port#
#export SP_SYS_HOST_NAME=seq
export IW_HOME=$SP_SYS_PRODDIR/util
#log into Shareplex Console
#`cd $SP_SYS_PRODDIR/bin`
/orahome/app/SharePlex/10g/prod/bin/./sp_ctrl << EOSP > $LOG_FILE
list config
repair $tblname
exit
EOSP
mailx -s "Table following table is now repairing in Shareplex SFGI<->CTXI Environment" myemail@email.com<< END
$tblname
`cat $LOG_FILE`
END
done
rm rowcount.txt
fi