################################################################################ # # File: switch # Purpose: Change ORACLE_SID environment variable # Used by: manual # Remark: Call with '. switch' otherwise your interactive shell's # environment will not change!! (of course you can make # an alias for '. switch' which may even be called 'switch'...) # Author: Gert de Boer # Date: 19.03.2001 # # Change history: # Who when what # -------- ---------- ---------------------------------------------------------- # ################################################################################ # Loop through the instances mentioned in /etc/oratab, and take the next # one cyclically. # Set start parameters: do_nothing=0 sid_found=0 # Generate list of active Oracle instances: oralist=$(grep -v '^#' /etc/oratab|grep ':Y$'|cut -d\: -f1) # Double it, in order to go back to the first instance in the list # if the last one is the actual one: oralist="$oralist $oralist" for sid in $oralist do # I presume the previous one is the active one... if [ $sid_found = 1 ] then # If switched already, do not switch anymore: if [ $do_nothing = 0 ] then # Otherwise, switch: export ORACLE_SID=$sid echo echo --------------------------------- echo Oracle instance is set to $sid echo --------------------------------- echo # and do not ever switch again... do_nothing=1 fi fi if [ $ORACLE_SID = $sid ] then # Prepare for switching: sid_found=1 fi done