At times it may be required to issue multiple compare/repair even though the users may want to control their execution so that it occurs in a serial order and not in parallel. The reasons can be many but mostly it has to do with resource usage during compare/repair.
The following script named run_compare.ksh can run multiple compare (or repair) one by one. The script will examine the text file named compare_command.txt located in the same directory as the script and will invoke the commands in that file which are compare or repair. It will issue the first compare or repair, then wait for it to finish before issuing another one and so on.
Here is a sample compare_command.txt
cat compare_command.txt
compare owner.source_table
repair owner.source_table1
Here is the script run_compare.ksh
# view run_compare.ksh
"run_compare.ksh" [Read only] 59 lines, 1370 characters
#!/bin/ksh
sp_ctrl="$SP_SYS_OPTDIR/bin/sp_ctrl"
runner ( )
{
sleepCnt=0
maxSleep=18000
Temp=something
echo "\n wait max. $maxSleep seconds (check every 2 seconds) for Compare to
complete.\n"
command=`cat $1`
echo "$sp_ctrl < $command"
$sp_ctrl < $1
while true
do
if [ $sleepCnt -gt $maxSleep ]
then
echo "\nThis compare took more than $maxSleep seconds to complete!!!"
return 1
else
:q!
# pwd
/
# mv run_compare.ksh /splex00/sha86
# cd /splex00/sha86
# more run_compare.ksh
#!/bin/ksh
sp_ctrl="$SP_SYS_OPTDIR/bin/sp_ctrl"
runner ( )
{
sleepCnt=0
maxSleep=18000
Temp=something
echo "\n wait max. $maxSleep seconds (check every 2 seconds) for Compare to
complete.\n"
command=`cat $1`
echo "$sp_ctrl < $command"
$sp_ctrl < $1
while true
do
if [ $sleepCnt -gt $maxSleep ]
then
echo "\nThis compare took more than $maxSleep seconds to complete!!!"
return 1
else
if [ ! -z "$Temp" ]
then
((sleepCnt=sleepCnt+2))
sleep 2
else
((min=sleepCnt/60))
((sec=sleepCnt-min*60))
echo "\n this test took approx. $min minutes $sec seconds to com
plete."
break;
fi
Temp=`ps -fe | grep -w sp_desvr |grep -v grep|grep -v vi|grep -v vedi
t`
fi
done
}
data_file="/quest/splex-home/kwong/support/compare_command.txt"
if [ ! -f $data_file ]
then
echo "\n\nCan not locate data file, $data_file\n\n"
exit;
fi
row_count=`wc -l $data_file|awk '{print $1}'`
integer i=1
tmp_command_file="/tmp/compare_command.txt-$$"
while (( $i<=$row_count));
do
print "$i: "
sed -n ''$i','$i'p' $data_file > $tmp_command_file
runner $tmp_command_file
(( i = i + 1 ));
done
# remove the temp command file
rm -f $tmp_command_file
200 PORT command successful.
150 Opening ASCII mode data connection for run_compare.ksh.
226 Transfer complete. 1,429 bytes transferred. 4.46 KB/sec.
local: run_compare.ksh remote: run_compare.ksh
1429 bytes sent in 0.0088 seconds (158.14 Kbytes/s)
ftp> bye
221 Goodbye, closing session.
#
As with all scripts, this script should be tested in one’s environment before deploying. The script is also attached with the Knowledgebase article.
© 2025 Quest Software Inc. ALL RIGHTS RESERVED. Terms of Use Privacy Cookie Preference Center