#!/bin/sh # # $DBA/file_use # # Report of all file specifications for the specified database ($1) # (Default of all databases) # # Last Change 03/29/96 by Brian Lomasky # if [ "$1" != "" ] then mysid=`fixcase $1` else mysid="" fi if [ -r file_use.lis ] then rm file_use.lis fi echo "" echo "Do you want to translate any symbolic links to their actual directories?" echo " Enter Y or N [Default of N] ==> \c" read yn echo "" myyn=`echo $yn | tr '[a-z]' '[A-Z]'` ORIIFS="$IFS" IFS="~" for LINE in `cat $TOOLS/database` do IFS="$ORIIFS" # # Extract the first parameter as the database SID # ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -` # # Process only if first field matches specified SID or no # parameter was specified # if [ "$ORACLE_SID" = "$mysid" -o "$mysid" = "" ] then SID=$ORACLE_SID . define is_dbo $ORACLE_SID if [ $? -eq 0 ] then echo "Skipping database $ORACLE_SID which is" \ "currently down..." else export ORACLE_SID echo "Processing $ORACLE_SID..." sqlplus -s / @$DBA/file_use $ORACLE_HOME if [ -r file_use.lis ] then cat file_use.lst >> file_use.lis rm file_use.lst else mv file_use.lst file_use.lis fi fi fi done IFS="$ORIIFS" # # See if we should replace all files which are symbolic links with the real # file name # if [ "$myyn" = "Y" ] then if [ -r file_use.new ]; then rm file_use.new; fi cat file_use.lis | while read THISFILE do # Extract the directory and the filename portion of the # filespec from each line of file_use.lis asterisk=`echo "$THISFILE" | awk '{ if (substr($0,1,7) == "*******") { print "*" } }' -` left=`echo "$THISFILE" | awk '{ x=index($0,"/") if (x != 0) { print substr($0,1,x-1) } }' -` mid=`echo "$THISFILE" | awk '{ x=index($0,"/") y=index(substr($0,x)," ") if (y == 0) y=length if (x > 4) { print substr($0,x,y-1) } }' -` right=`echo "$THISFILE" | awk '{ x=index($0,"/") y=index(substr($0,x)," ") if (x != 0 && y != 0) { print substr($0,x+y-1) } }' -` # Skip if no slash was found if [ "$mid" = "" ]; then if [ "$asterisk" = "*" ]; then echo " $THISFILE" >> file_use.new else echo "$THISFILE" >> file_use.new fi continue fi # See if last directory in the filespec is a symbolic link thedir=`dirname $mid` thenam=`basename $mid` REALLINK=`ls -ld ${thedir} | awk '{print $NF}'` if [ "$thedir" = "$REALLINK" ]; then # See if the file in the filespec is a symbolic link if [ -r $mid ]; then REALLINK=`ls -ld ${mid} | awk '{print $NF}'` if [ "$mid" = "$REALLINK" ]; then echo "$THISFILE" >> file_use.new continue fi else echo "$THISFILE" >> file_use.new continue fi fi mid=`echo "$mid" | awk '{ while (length(rl) < length($0)) rl=rl " " print rl }' rl="$REALLINK/$thenam"` echo "$left$mid$right" >> file_use.new done rm file_use.lis mv file_use.new file_use.lis fi # # PRINT/DELETE the report file # echo "" #cat file_use.lis #bq1 file_use.lis #rm file_use.lis