find home


#!/bin/ksh 
# 
# find_ohome.sh 
# Script to find the ORACLE_HOME value from /etc/oratab using the 
# ORACLE_SID supplied as a parameter 
# 
# 
################################################# 
# Verify if oracle SID is passed as a parameter # 
################################################# 
if test $# -ne 1 
then 
 echo NOSIDNAME 
 return 1 
fi 
PSID=$1 
############################################################################ 
# Read /etc/oratab file to find ORACLE_HOME for the supplied instance name # 
############################################################################ 
cat /etc/oratab | while read LINE 
do 
 case $LINE in 
 \#*) ;; #comment-line in oratab 
 *) 
 #Proceed only if third field is 'Y'. 
# if [ "`echo $LINE | awk -F: '{print $3}' -`" = "Y" ] 
# then 
 OSID=`echo $LINE | awk -F: '{print $1}' -` 
 if [ "$OSID" = "$PSID" ] 
 then 
 OHOME=`echo $LINE | awk -F: '{print $2}' -` 
 echo $OHOME 
 return 0 
 fi 
# fi 
 esac 
done 
echo INVALIDSID 
return 1 
################# 
# End of Script # 
#################
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: