#!/bin/ksh # To view / change current Oracle SID and ORALCE_HOME, PATH # # Biju Thomas - 10/15/97 # Modified - 13/02/98 - Add PATH feature! # echo ' ' echo '********************************************************************************' echo ' The current ORACLE_SID value is ' $ORACLE_SID echo '********************************************************************************' echo ' The following are valid instance names along with the ORACLE_HOME value:' echo ' ' wcntr=0 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 wcntr=`expr $wcntr + 1` OSID=`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" = '*' ] ; then echo ' *** Unknown Value ***' fi OHOME=`echo $LINE | awk -F: '{print $2}' -` echo ' Slno:' $wcntr ' SID Name:' $OSID ' Oracle Home:' $OHOME #fi esac done < /etc/oratab echo ' ' echo '********************************************************************************' echo ' ' echo ' Do you want to change ORACLE_SID [Y/N]? \c' read choice case $choice in Y|y) continue;; *) return 0;; esac echo ' Enter Slno of the SID from above list : \c' read choice if test $choice -lt 0 || test $choice -gt $wcntr then echo ' Invalid choice.... Sorry!!!' return 1 fi wcntr=0 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 wcntr=`expr $wcntr + 1` if test $wcntr -eq $choice then ORACLE_SID=`echo $LINE | awk -F: '{print $1}' -` if [ "$ORACLE_SID" = '*' ] ; then ORACLE_SID='' fi ORACLE_HOME=`echo $LINE | awk -F: '{print $2}' -` export ORACLE_HOME ORACLE_SID break; fi #fi esac done < /etc/oratab # # Change PATH with new oracle home # path=`echo $PATH | sed "s/:/ /g"` NEWPATH=$ORACLE_HOME/bin for dirname in $path do if [ `echo $dirname | grep oracle | grep bin | wc -l` -eq 0 ] then NEWPATH=`echo ${NEWPATH}:${dirname}` fi done export PATH=$NEWPATH export ORA_NLS= # echo ' ' echo '********************************************************************************' echo ' New value of ORACLE_SID is ' $ORACLE_SID echo ' New value of ORACLE_HOME is ' $ORACLE_HOME echo ' New value of PATH is ' $PATH echo '********************************************************************************' echo ' ' #