Goto script (goto)



Goto script (goto)


Description
  • Change to different database or ORACLE_HOME.
  • Dedepencies – requires avail script.

#! /bin/ksh
# Filename:     /home/oracle/goto
#
# Usage: . goto SID     # where SID is the required ORACLE instance.
#
#
# Changes ORACLE instance and sets environment accordingly.
# May be called by application .ini files in /local/apps/*
#
# DO NOT COPY THIS SCRIPT OUT
# ----------------------------------------------------------------------------------------------
SAV_SID=${ORACLE_SID:-}
SAV_HOME=${ORACLE_HOME:-}
ORAENV_ASK=NO   export ORAENV_ASK
ORACLE_ETC=/home/oracle
ORACLE_BASE=/oracle
#
# ----------------------------------------------------------------------------------------------
# Determine how to suppress newline with echo command.
#
if echo "\c" | grep c >/dev/null 2>&1; then
        N='-n'
else
        C='\c'
fi
#
# And find ORATAB
#
if [ -f /etc/oratab ]  ;  then
        ORATAB=/etc/oratab
else
        echo "No oratab file found.. Cannot use 'goto'"
        exit 1
fi;
#
# -----------------------------------------------------------------
# Use Parameter if provided !! Else get one
#
if  [ "${1:-}" = "" ] ;  then
         ${ORACLE_ETC}/avail
         echo ${N:-} "Oracle SID [$SAV_SID] ?  : $C"
         read SID
else
         SID="$1"
         shift  # prevent $1 from contaminating calling environment
fi;
echo
# ----------------------------------------------------------------
# And relocate us !!
#
if  [  "$SID"  != "" ]; then
        ORACLE_SID=$SID;        export ORACLE_SID;
        . ${ORACLE_HOME}/bin/oraenv
        unset ORAENV_ASK HTE_GOTO

        #
        # Set ORACLE_TERM (used by orainst and SQL*DBA via toolkit 2)
        # (Terminals with resource files in $ORACLE_TERMINAL directory are supported -
        #  - edit the case $TERM statement below if necessary.)
        # ORAKITPATH and ORATERMPATH are for toolkit 1 apps. only.
        # ORACLE_TERM and ORACLE_TERMINAL are for toolkit 2 apps. only.
        #
        case $TERM in
                aixterm|hft|lft|xterm)  ORACLE_TERM=lft ;;
                                    *)  ORACLE_TERM=vt100 ;;
        esac

        ORAKITPATH=$ORACLE_HOME/forms30/admin/resource  # Used by Forms 30, Menu 5 and ORACLE
        # Terminal, if they cannot find their resources in $MENU5PATH and $ORATERMPATH.
        MENU5PATH=$ORACLE_HOME/forms30/admin/resource   # Used by SQL*Menu version 5.
        ORATERMPATH=$ORACLE_HOME/oraterm/admin/resource # Used by ORACLE Terminal.
        TNS_ADMIN=${ORACLE_HOME}/network                  # used for MTS and sqlnetv2
        ORA_NLS32=$ORACLE_HOME/ocommon/nls/admin/data  # Used to creating a database with a character set other than US7ASCII
        export ORACLE_TERM ORAKITPATH MENU5PATH ORATERMPATH TNS_ADMIN ORA_NLS32
else
        echo "No change made to Environment"
fi;

========================================================

Sample Output

/home/oracle
oracle@bina83_FXPGSM1 $ . goto

The following databases are available :

ORACLE_SID      ORACLE_HOME             Running?

FXPGSM1         /oracle/9.2.0           yes
FXPGSM2         /oracle/9.2.0           yes
FXPROAM         /oracle/9.2.0           yes
GCAgentHome             /oracle/OEM/agent10g            yes
FXPGSM3         /oracle/9.2.0           yes
FXPGSM4         /oracle/9.2.0           yes
GSM2OLD         /oracle/9.2.0           no
Oracle SID [FXPGSM1] ?  : FXPROAM


/home/oracle
oracle@bina83_FXPROAM $

No comments:

Post a Comment