Oracle环境变量设置脚本

每次都傻乎乎的往bashrc里面写环境变量,感觉不任性。于是,看了本书了解了/etc/oratab这个东东后,参考着书也写了一个设置Oracle环境变量的脚本。

在/etc/下创建oraset,权限设置为chown oracle:oinstall /etc/oraset

oraset内容:

#!/bin/bash

# Sets Oracle environment variables.

# Setup: 1. Put oraset file in /etc(Linux), in /var/opt/oracle(Solaris)

#        2. Ensure /etc or /var/opt/oracle is in $PATH

# Usage: batch mode: . oraset <SID>

#        menu mode: . oraset

#=======================================================

if [ -f /etc/oratab ]; then

    OTAB=/etc/oratab

elif [ -f /var/opt/oracle/oratab ]; then

    OTAB=/var/opt/oracle/oratab

else

    echo 'oratab file not found.'

    exit

fi

#

if [ -z $1 ]; then

    SIDLIST=$(egrep -v '#|\*' ${OTAB} | cut -f1 -d:)

    # PS3 inmdicates the prompt to be used for the Bash select command.

    PS3='SID?'

    select sid in ${SIDLIST}; do

        if [ -n $sid ]; then

            HOLD_SID=$sid

            break;

        fi

    done

else

    if egrep -v '#|\*' ${OTAB} | grep -w "${1}:">/dev/null; then

        HOLD_SID=$1

    else

        echo "SID: $1 not found in $OTAB"

    fi

    shift

fi

#

ORACLE_SID=$HOLD_SID

export ORACLE_SID

export ORACLE_HOME=$(egrep -v '#|\*' ${OTAB} | grep -w $ORACLE_SID:|cut -f2 -d:)

export ORACLE_BASE=${ORACLE_HOME%%/product*}

export TMP=$ORACLE_BASE/../tmp

export TMPDIR=$TMP

export TNS_ADMIN=$ORACLE_HOME/network/admin

export ADR_BASE=$ORACLE_BASE/diag

export PATH=$PATH:$ORACLE_HOME/bin

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME/lib

然后在oracle用户的.bashrc里面添加:

source /etc/oraset xxxx

注:

1. xxxx为你SID的名称。

2. 路径以个人安装为准。

3. 谁知道怎么在Live Writer的代码亮度插件里添加行号和奇偶行不同色?

 

附:

系统:Red Hat Enterprise Linux7.0

Oracle:12c Enterprise

 

转载请注明出处····································

你可能感兴趣的:(oracle)