Experience: is what you get soon after you need it.

Experience: is what you get soon after you need it.

Rasul Allah (sal Allahu alaihi wa sallam) said: "Restore the trusts of those who trust you, and deal not falsely with him who deals falsely with you." [Abu Dawud, Tirmidhi]

Search This Blog

Thursday, August 13, 2015

Setting up the oracle environment

I have three Oracle databases and each have its own environment that needs to be run.

Ex:-

1.ORCL
2.PROD1
3.GRID

Wrote a small crude shell script to run the env files.

[oracle@collabn1 ~]$ vi setup_ora_env.sh

#!/bin/bash
function unset1
{
echo "You are in func"
unset ORACLE_SID ORACLE_BASE TNS_ADMIN ORACLE_HOME
export PATH=/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/oracle/bin
}

k=1
echo -e "\n"
echo -e "You have below ENV files..."
array1=( $(ls ~/*.env) )
for i in "${array1[@]}";do
echo "Select $k for $i"
let "k=$k+1"
done
echo -e "\n"

#Unsetting the ORA ENV variables
unset1

echo -e "Enter your choince now:        "
read input
if [ $input -eq 1 ];then
echo -e "\n"
echo -e "Running environment file...   ${array1[0]}"
. ${array1[0]}
elif [ $input -eq 2 ];then
echo -e "\n"
echo -e "Running environment file...    ${array1[1]}"
.  ${array1[1]}
elif [ $input -eq 3 ];then
echo -e "\n"
echo -e "Running environment file...    ${array1[2]}"
. ${array1[2]}
else
echo -e "Wrong choice...Plz try again"
fi

No comments: