首页 > 代码库 > Oracle环境变量设置脚本

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/oratabelif [ -f /var/opt/oracle/oratab ]; then    OTAB=/var/opt/oracle/oratabelse    echo oratab file not found.    exitfi#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    doneelse    if egrep -v #|\* ${OTAB} | grep -w "${1}:">/dev/null; then        HOLD_SID=$1    else        echo "SID: $1 not found in $OTAB"    fi    shiftfi#ORACLE_SID=$HOLD_SIDexport ORACLE_SIDexport ORACLE_HOME=$(egrep -v #|\* ${OTAB} | grep -w $ORACLE_SID:|cut -f2 -d:)export ORACLE_BASE=${ORACLE_HOME%%/product*}export TMP=$ORACLE_BASE/../tmpexport TMPDIR=$TMPexport TNS_ADMIN=$ORACLE_HOME/network/adminexport ADR_BASE=$ORACLE_BASE/diagexport PATH=$PATH:$ORACLE_HOME/binexport 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环境变量设置脚本