Hi
I am posting my script.I know its too big but please help!!!!!
Quote:
logcountfunction()
{
awk ' {
# when executing the script pass the logfile as parameter on the command prompt with the name of the file
#export file_name= "&1"
if (index ( $0, ". . exporting table") >0 || index ($0, ". . exporting partition") >0)
#searching for the pattern in string
{
if ($4 != "partition"){
#$4 is either table or a partition
i=$6;
#$6 is the number of rows stored in variable i here
if (table_flag ==0 && table_name ==temp_table_name){
# checking the flag
printf table_name > "logcountOP";
printf "-" > "logcountOP";
print j > "logcountOP";
}
table_name = $5;
#$5 has the name of the table from which the rows have been imported
temp_table_name = table_name;
table_flag =1;
#setting the flag to 1
}
if ($4 == "partition") {
i=i+$6;
#summing up the rows in partitioned tables
printf("value of i in first: %d\n",i);
j=i;
table_flag=0;
#setting flag to 0
}
if (table_flag !=0 && $6 !=""){
printf table_name >> "logcountOP";
printf "-" >> "logcountOP";
print i >> "logcountOP";
}
}
} ' < $1
}
echo -------------------------------------------------------------
#!/bin/ksh
DBcounttry_finalnofunc()
{
cat logcountOP | while read LINE
TBLName=`echo $LINE|cut -d "-" -f1`
do
if [ $LINE != "" ]
then
printf "${TBLName}-" $TBLName
return_count=$(sqlplus -s a/a@abs5 <<EOF
set heading off feedback off pagesize 0 linesize 30000 trimout on;
whenever sqlerror exit 1;
whenever oserror exit 1;
select count (*) from ${TBLName};
exit 0;
EOF)
if [ $return_count -ge 0 ]
then
print "${TBLName}- ${return_count}" >> DBcountOP400
else
echo "$TBLName- is missing" >> DBcountOP400
fi
else
exit
#break
fi
done > DBcountOP3
}
echo -------------------------------------------------------------------------
#!/bin/ksh
comparingloganddbOP()
{
#!/bin/sh
comm -3 logcountOP DBcountOP400 >c.txt
#shows diff
comm -1 logcountOP DBcountOP400 >d.txt
#shows common
}
echo -----------------------------------------------------------------------------
#!/bin/ksh
formattingscript()
{
sed '1,2d' c.txt > newc.txt
awk 'BEGIN{RS="\n\n"} {printf("%s %s\n", $1, $2)}' newc.txt > newcOP.txt
awk 'BEGIN {x = 0}
{
if (x<2) {
printf("%s ",$0)
x=x+1
}
if (x==2) {
printf("\n")
x = 0
}
}' newcOP.txt > newcOP2.txt
}
echo ----------------------------------------------------------------------------------
#!/bin/ksh
finalstatusOP()
{
export file="newcOP2.txt"
while read FILE_LINE ; do
LINE1="$(echo $FILE_LINE | cut -d '-' -f1)"
tablename1="$(echo $LINE1 | cut -d ' ' -f1)"
#echo tablename1 is $tablename1
count1="$(echo $FILE_LINE | cut -d ' ' -f2)"
#echo count1 is $count1
LINE2="$(echo $FILE_LINE | cut -d ' ' -f3)"
tablename2="$(echo $LINE2 | cut -d '-' -f1)"
count2="$(echo $LINE2 | cut -d '-' -f2)"
#echo tablename2 is $tablename2
#echo count2 is $count2
if [ $count1 = "is" ]
then
#echo missing
echo status for $tablename1- does not exist in DB >> statusOP
elif [ $count1 -eq $count2 ]
then
#echo match
echo status for $tablename2 $count2 $count1- match >> statusOP
elif [ $count1 -ne $count2 ]
then
#echo mismatch
echo status for $tablename2 $count2 $count1- mismatch >> statusOP
fi
done < $file
}
##############################MAIN SCRIPT STARTS HERE
#!/bin/ksh
echo "please exit and execute the script again alongwith the logfile name"
. ./logcount
logcountfunction "$1"
. ./DBcounttry_finalnofunc
DBcounttry_finalnofunc
. ./comparingloganddbOP
comparingloganddbOP
. ./formattingscript
formattingscript
. ./finalstatusOP
finalstatusOP
|
now, the first funtion is taking a logfile as input.The sample is given below:
Quote:
. . exporting table MTM_X79COUNTRY1_X79TZONE0 0 rows exported
. . exporting table MTM_X79LOCATION1_X79SERVICE3 0 rows exported
. . exporting table MTM_X79TELCOM_TR1_X79MO_INST2 0 rows exported
. . exporting table MTM_X79TELCOM_TR2_X79MO_INST1 0 rows exported
. . exporting table MTM_X_MDU_CONTRACT5_X_MDUCLU2 0 rows exported
. . exporting table OMSE1_XML_DISTRIB 0 rows exported
. . exporting table SEC1_LOG
. . exporting partition PR001_P1 0 rows exported
. . exporting partition PR002_P2 0 rows exported
. . exporting partition PR003_P3 0 rows exported
. . exporting partition PR004_P4 0 rows exported
. . exporting partition PR005_P5 0 rows exported
|
the second function is taking the output file of first function as input,i.e,logcountOP which looks like:
Quote:
ACCOUNT_MISSING_FRM_RCIS_LINK-4
ADP_COMMENT-2311
ADP_CONFIG-11
ADP_FIELD-36323
ADP_HEADER-1
ADP_INDEX-579
ADP_JOIN-14570
ADP_LANGUAGE-2
ADP_NATIVE_SQL-228
ADP_OBJECT-2405
ADP_OBJECT_NEW-2010
ADP_RELATION-4974
ADP_TBL_OID-838
ADP_TBL_OID_UNUSED-0
ADP_UPGRADE_OPS-0
|
the output of second function looks like:-
Quote:
ACCOUNT_MISSING_FRM_RCIS_LINK- is missing
ADP_COMMENT- 2384
ADP_CONFIG- 11
ADP_FIELD- 36333
ADP_HEADER- 1
ADP_INDEX- 609
ADP_JOIN- 14572
ADP_LANGUAGE- 2
ADP_NATIVE_SQL- 228
ADP_OBJECT- 2405
ADP_OBJECT_NEW- is missing
ADP_RELATION- 4974
ADP_TBL_OID- 839
ADP_TBL_OID_UNUSED- 0
ADP_UPGRADE_OPS- 0
ADP_VIEW_FIELD- 43791
|
my problem is that when i execute this script only the first two functions are being called.once the
DBcounttry_finalnofunc() is done ,the script exits.The rest of the functions are not being called.Please point out where am I goin wrong!!!!