#!/bin/ksh if [[ $1 = -i ]] then Dcasesens=-i shift else Dcasesens= fi if [[ $# < 1 ]] then echo echo copf - Compare Oracle Parameter Files echo echo 'Usage: copf [ -i ] file1 file2' echo ' or: copf [ -i ] oracle_sid' echo echo "In the first usage, any of the given files can be either init*.ora or spfile*.ora file types." echo 'In the second usage, when only one argument is given, it is treated as an Oracle SID, and ' echo ' init{oracle_sid}.ora and spfile{oracle_sid}.ora files from $ORACLE_HOME/dbs directory are compared.' echo echo The -i option makes the comparison case-insensitive. echo exit 2 fi if [[ $# = 1 ]] then Dfile1=$ORACLE_HOME/dbs/spfile$1.ora Dfile2=$ORACLE_HOME/dbs/init$1.ora else Dfile1=$1 Dfile2=$2 if [[ $Dfile1 -ef $Dfile2 ]] then echo $Dfile1 and $Dfile2 refer to the same file. exit fi fi if [[ ! -f $Dfile1 ]] then echo File $Dfile1 not found. exit 2 fi if [[ ! -f $Dfile2 ]] then echo File $Dfile2 not found. exit 2 fi function Dconvertinit { # rmv comments rmv empty lines rmv quotes rmv leading *. process multi-line entries grep -v '^[ ]*#' $1 |grep -v '^[ ]*$'|tr -d '"' | tr -d "'" | sed 's/^\*\.//' | sed -n ' { # check if the line begins with something like "*?.?param_name=(" /^*\{0,1\}\.\{0,1\}\<.*\>=[ ]*(/b paren :print p b :rmvpar # assuming a line beginning with "*.param_name=(" will not have any right parentheses # other than the last closing one, possibly in one of the following lines. # if there is more than one open parentheses, just print the line s/(/(/2 t print # remove the left parenthesis in "*?.?param_name=(" s/^\(*\{0,1\}\.\{0,1\}\<.*\>=[ ]*\)(/\1/ # remove the last parenthesis s/)$// b print :paren /)/b rmvpar h :cont n /)/b end H b cont :end H x s/\n//g b rmvpar } ' | sort -u > $1.2 } function Dconvertsp { if [[ ! -z $ORACLE_SID ]] then unset ORACLE_SID fi sqlplus -s '/ as sysdba'<<-eof! set feedback off create pfile='$1.1' from spfile='$1'; exit eof! sed 's/^\*\.//' $1.1 | tr -d "'" > $1.2 rm $1.1 } if file $Dfile1 | /usr/xpg4/bin/grep -q 'ascii text$' ; then Dconvertinit $Dfile1 else Dconvertsp $Dfile1 fi if file $Dfile2 | /usr/xpg4/bin/grep -q 'ascii text$' ; then Dconvertinit $Dfile2 else Dconvertsp $Dfile2 fi if [[ `basename $Dfile1` = `basename $Dfile2` ]] then Dshort1=`echo $Dfile1|sed 's/\//\\\\\//g'` Dshort2=`echo $Dfile2|sed 's/\//\\\\\//g'` else Dshort1=`basename $Dfile1` Dshort2=`basename $Dfile2` fi diff -btw $Dcasesens $Dfile1.2 $Dfile2.2 | sed "s/^rm $Dfile1.2 $Dfile2.2