#!/bin/ksh # # Creates a dictionary file of the database $ORACLE_SID # # AUTHOR: M. Wunderli, Trivadis AG, Kanalstrasse 5, 8152 Glattbrugg # # VERSION: 1.1, 1999-09-30, MaW # 1.2, 1999-10-10, MaW, fixed bug in utl_file_dir scanning # 1.3, 1999-11-04, MaW, cosmetics # # BUGS: # - none, only features ;-) # Usage () { cat << _EOI Usage: `basename $0` -d [-p ] The script must be run on the machine on which the database resides. ORACLE_SID and ORACLE_HOME must be set, dbms_logmnr_d package must be installed. The password for the internal user may be passed as a parameter but is not necessary if the executing user is of group dba. _EOI exit 1 } Quit () { echo $1 exit 1 } # Evaluate parameters DictFile="" InternalConnect="internal" while getopts d:p: Option do case ${Option} in d) DictName="${OPTARG}" ;; p) InternalConnect="internal/""${OPTARG}" ;; esac done # Sanity checks if [ -z "$ORACLE_SID" ] then Quit "ORACLE_SID not set!" fi if [ -z "$ORACLE_HOME" -o ! -f $ORACLE_HOME/dbs/init${ORACLE_SID}.ora ] then Quit "Cannot check init${ORACLE_SID}.ora! Check ORACLE_HOME and the parameter file!" fi if [ "$DictName" = "" ] then Usage Exit 1 fi DictFile=`basename $DictName` DictDir=`dirname $DictName` if [ "`echo $DictDir | cut -c1`" != "/" ] then Quit "Error. No absolute path for dictionary file given!" fi utl_file_dir="`svrmgrl << _EOI | grep -v grep | grep 'utl_file_dir ' | grep ' '"$DictDir" connect $InternalConnect select name,value from v\\\$parameter where name = 'utl_file_dir'; _EOI `" if [ "$utl_file_dir" = "" ] then Quit "Dictionary directory not found in utl_file_dir parameter of $ORACLE_SID!" fi # Do it echo "Just a moment please..." svrmgrl << _EOI > /dev/null 2>&1 connect $InternalConnect begin dbms_logmnr_d.build('$DictFile','$DictDir'); end; / _EOI echo "Done:" ls -al $DictName