Search This Blog

Total Pageviews

Thursday, 22 September 2011

Oracle user bash_profile file

.bash_profile on linux 
bash_profile
.profile on solaris 
profile on solaris



!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

on linux 


oracle@apt-amd-02:~> cat .bash_profile
export ORACLE_BASE=/opt/app/oracle
#export ORACLE_HOME=/opt/app/oracle/product/10.2
export ORACLE_HOME=/opt/app/oracle/product/11.2
export TNS_ADMIN=/opt/app/oracle/product/11.2/network/admin
# export ORACLE_HOME=/opt/app/oracle/product/app10.2
export ORACLE_SID=orcl




export ORACLE_HOME=/opt/oracle/product/10.2
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH:.



export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH:.
export LIBXCB_ALLOW_SLOPPY_LOCK=1
export TZ=GMT
export GGATE=/opt/app/oracle/product/gg
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib:/u01/app/oracle/product/gg

alias alert='tail -f -n100 $ORACLE_BASE/diag/rdbms/$SDBNAME/$ORACLE_SID/trace/alert_$ORACLE_SID.log'
alias bdump='cd $ORACLE_BASE/diag/rdbms/$SDBNAME/$ORACLE_SID/trace'
alias cdb='cd $ORACLE_BASE'
alias cdo='cd $ORACLE_HOME'

===

on solaris




-bash-3.00$ cat .bashrc


map! A 

map! B 

map! ^[OD ^[

map! ^[OC ^[ll





alias aaa='sqlplus / as sysdba'          # prompt before overwrite

alias alert='tail -100  /opt/oracle/admin/db/bdump/alert_db.log|more' 
alias rma='rm -i'          # prompt before overwrite
alias cpa='cp -i'
# alias mva='mv -i'
alias arch1='cd  /opt/oracle/admin/db/arch'
alias spfile='cd /opt/oracle/product/10.2/dbs'
# /opt/oracle/admin/db/arch
alias sid='env|grep ORACLE_SID'

alias aalert='vi + $(printf "set heading off pages 0 feedback off select value from v\$parameter where name='\''background_dump_dest'\'';"|sqlplus -S "/ as sysdba")/alert_${ORACLE_SID}.log'



alias xalert='/usr/bin/vi + $(printf "set heading off pages 0 feedback off\n select value from v\$parameter where name='\''background_dump_dest'\'';\n"|sqlplus -S "/ as sysdba")/alert_${ORACLE_SID}.log'






-bash-3.00$ cat .profile
#       This is the default standard profile provided to a user.
#       They are expected to edit it to meet their own needs.

MAIL=/usr/mail/${LOGNAME:?}
ORACLE_BASE=/opt/oracle; export ORACLE_BASE
ORACLE_HOME=${ORACLE_BASE}/product/10.2; export ORACLE_HOME
ORACLE_SID=db; export ORACLE_SID
PATH=/usr/bin:/usr/sbin:/usr/local/bin:$ORACLE_HOME/bin:$ORACLE_HOME/jdk:$ORACLE_HOME/perl5:$PATH; export PATH
TMPDIR=/var/tmp
TERM=vt220
ORACLE_TERM=vt220
UMASK=022
EDITOR=vi; export EDITOR
NLS_LANG="ENGLISH_UNITED KINGDOM.UTF8"; export NLS_LANG
# Use the following line for import/export only
#NLS_LANG="ENGLISH_UNITED KINGDOM.AL32UTF8"; export NLS_LANG
LC_ALL=en_US.UTF-8; export LC_ALL
ORA_NLS33=$ORACLE_HOME/ocommon/nls/admin/data; export ORA_NLS33
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:$ORACLE_HOME/ctx/lib:$ORACLE_HOME/ctx/bin:$LD_LIBRARY_PATH; export LD_LIBRARY_PATH
. \.brc


==========

 
 export ORACLE_PDB_SID=ORCLPDB  <<<<< change based on requirement ORACLE_SID_PDB - Connect as SYSDBA without password into a PDB directly
 
 sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Dec 25 08:00:17 2021
Version 19.12.0.0.0

Copyright (c) 1982, 2021, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.12.0.0.0

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 ORCLPDB                        READ WRITE NO


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


 stty erase ^?
 stty erase ^H

 cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/.local/bin:$HOME/bin

export PATH
export ORACLE_HOME=/u01/app/oracle/product/19.0.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=prod

##  
export ORACLE_SID=ORCL
RAC=NO
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export ORACLE_BASE=/u01/app/oracle

## based on your requirement !!!!

export EDITOR=vi
PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
SORACLE_SID=`echo $ORACLE_SID | tr '[:upper:]' '[:lower:]'`

if [ $RAC = 'NO' ] ; then
     SDBNAME=$SORACLE_SID
     ORACLE_UNQNAME=$ORACLE_SID
  else
     SDBNAME=`echo $SORACLE_SID | sed s/.$//`
     ORACLE_UNQNAME=`echo $ORACLE_SID | sed s/.$//`
fi

export ORACLE_UNQNAME
alias cdo='cd $ORACLE_HOME'
alias cdb='cd $ORACLE_BASE'
alias bdump='cd $ORACLE_BASE/diag/rdbms/$SDBNAME/$ORACLE_SID/trace'
alias udump='cd $ORACLE_BASE/diag/rdbms/$SDBNAME/$ORACLE_SID/trace'
alias alert='tail -f -n100 $ORACLE_BASE/diag/rdbms/$SDBNAME/$ORACLE_SID/trace/alert_$ORACLE_SID.log'

alias sqlme='sqlplus / as sysdba'
alias home='cd $ORACLE_HOME'
alias db='export ORACLE_SID=orcl'
alias alert_db='tail -100f /u01/oracle/11.2.0/diag/rdbms/testdb/testdb/trace/alert_testdb.log'

## End


***************************************************







cat .bash_profile

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export TMOUT=
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
#export ORACLE_SID=

PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$PATH:$HOME/bin

alias DBV='cd /u01/app/dbvisit/dbvisit/standby'


export PATH
cat /etc/oratab




# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export TMOUT=
export ORACLE_BASE=/u01/app/oracle
#export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export ORACLE_SID=ibrac1

export GG_HOME=/dumps/gghome_capture
export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GG_HOME:$PATH:$HOME/.local/bin:$HOME/bin

export PATH


echo " -MGMTDB /u01/app/12.2.0/grid "
echo " +ASM1   /u01/app/12.2.0/grid "
echo " ibrac1  /u01/app/oracle/product/12.2.0/dbhome_1 "
echo " capture /u01/app/oracle/product/12.1.0/dbhome_1 "
echo "  "
echo "  "
echo "  "
echo "  "

EDITOR=vi
SQLPATH=/home/oracle/dba
export PATH EDITOR SQLPATH

export ORACLE_PATH=/home/oracle/dba/






setsid ()
{
unset ORATAB
unset ORACLE_BASE
unset ORACLE_HOME
unset ORACLE_SID
ORACLE_BASE=/u01/app/oracle
ORATAB=/etc/oratab
if tty -s
then
        if [ -f $ORATAB ]
        then
                line_count=`cat $ORATAB | grep -v ^# | sed 's/:.*//' | wc -l`
                # check that the oratab file has some contents
                if [ $line_count -ge 1 ]
                        then
                        sid_selected=0
                        while [ $sid_selected -eq 0 ]
                        do
                                sid_available=0
                                for i in `cat $ORATAB | grep -v ^# | sed 's/:.*//'`
                                        do
                                        sid_available=`expr $sid_available + 1`
                                        sid[$sid_available]=$i
                                        done
                                # get the required SID
                                case ${SETSID_AUTO:-""} in
                                        YES) # Auto set use 1st entry
                                        sid_selected=1 ;;
                                        *)
                                        i=1
                                        while [ $i -le $sid_available ]
                                        do
                                                printf "%2d- %10s\n" $i ${sid[$i]}
                                                i=`expr $i + 1`
                                        done
                                        echo ""
                                        echo "Select the Oracle SID with given number [1]:"
                                        read entry
                                        if [ -n "$entry" ]
                                        then
                                                entry=`echo "$entry" | sed "s/[a-z,A-Z]//g"`
                                                if [ -n "$entry" ]
                                                then
                                                        entry=`expr $entry`
                                                        if [ $entry -ge 1 ] && [ $entry -le $sid_available ]
                                                        then
                                                                sid_selected=$entry
                                                        fi
                                                fi
                                                else
                                                sid_selected=1
                                        fi
                                esac
                        done
                        #
                        # SET ORACLE_SID
                        #
                        export ORACLE_SID=${sid[$sid_selected]}
                        echo "Your profile configured for $ORACLE_SID with information below:"
                        echo ""
                        export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/bin
                        unset LD_LIBRARY_PATH
                        ORAENV_ASK=NO
                        . oraenv
                        alias oh="cd ${ORACLE_HOME}"
                        ora_version=`echo $ORACLE_HOME | awk 'BEGIN {FS="/"} ; {print $6}' | awk 'BEGIN {FS="."} ; {print $1}'`
                        if [ $ora_version -lt 11 ]
                        then
                        alias bdump="cd /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump"
                        alias talert="tail -f /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        alias valert="view /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        fi
                        if [ $ora_version -ge  11 ]
                        then
                        export ORACLE_UNQNAME=$ORACLE_SID
                        alias talert='tail -f $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias valert='view $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias alasm='cd $ORACLE_BASE/`adrci exec="show homes" | grep ASM`/trace'
                        alias bdump='cd $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace'
                        fi
                        alias pmon='ps -fu oracle | grep pmon | grep -v grep'
                        alias tns='ps -fu oracle | grep tns | grep -v grep'
                        alias oradiag='cd $ORACLE_BASE/diag/'
                        alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'
                        unset ORAENV_ASK
                        echo
                        #
                        #GIVE MESSAGE
                        #
                        else
                        echo "No entries in $ORATAB. no environment set"
                fi
        fi
fi
}

setsid


showsid()
{
echo ""
echo "ORACLE_SID=$ORACLE_SID"
echo "ORACLE_BASE=$ORACLE_BASE"
echo "ORACLE_HOME=$ORACLE_HOME"
echo "alias oh=cd ${ORACLE_HOME}"
echo "alias pmon='ps -fu oracle | grep pmon | grep -v grep'"
echo "alias tns='ps -fu oracle | grep tns | grep -v grep'"
ora_version=`echo $ORACLE_HOME | awk 'BEGIN {FS="/"} ; {print $6}' | awk 'BEGIN {FS="."} ; {print $1}'`
if [ $ora_version -ge  11 ]
then
echo "alias talert='tail -f $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'"
echo "alias valert='view $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'"
echo "alias bdump='cd $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace'"
echo "alias alasm='cd $ORACLE_BASE/`adrci exec="show homes" | grep ASM`/trace'"
echo "alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'"
echo "alias oradiag='cd $ORACLE_BASE/diag/'"
fi
if [ $ora_version -lt 11 ]
then
echo "alias bdump=cd /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump"
echo "alias talert=tail -f \"/u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log\""
echo "alias valert=\"view /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log\""
echo "alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'"
fi
echo ""
}

showsid


sqlplus / as sysdba



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


[oracle@wcp12cr2 ~]$ cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH


# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export TMOUT=
export ORACLE_BASE=/oracle/db
export ORACLE_HOME=/oracle/db/ohome
export ORACLE_SID=orcl

export GG_HOME=/dumps/gghome_capture
export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GG_HOME:$PATH:$HOME/.local/bin:$HOME/bin

export PATH

echo " orcl  /oracle/db/ohome "

echo "  "
echo "  "
echo "  "
echo "  "

EDITOR=vi
SQLPATH=/home/oracle/dba
export PATH EDITOR SQLPATH

export ORACLE_PATH=/home/oracle/dba/






setsid ()
{
unset ORATAB
unset ORACLE_BASE
unset ORACLE_HOME
unset ORACLE_SID
ORACLE_BASE=/u01/app/oracle
ORATAB=/etc/oratab
if tty -s
then
        if [ -f $ORATAB ]
        then
                line_count=`cat $ORATAB | grep -v ^# | sed 's/:.*//' | wc -l`
                # check that the oratab file has some contents
                if [ $line_count -ge 1 ]
                        then
                        sid_selected=0
                        while [ $sid_selected -eq 0 ]
                        do
                                sid_available=0
                                for i in `cat $ORATAB | grep -v ^# | sed 's/:.*//'`
                                        do
                                        sid_available=`expr $sid_available + 1`
                                        sid[$sid_available]=$i
                                        done
                                # get the required SID
                                case ${SETSID_AUTO:-""} in
                                        YES) # Auto set use 1st entry
                                        sid_selected=1 ;;
                                        *)
                                        i=1
                                        while [ $i -le $sid_available ]
                                        do
                                                printf "%2d- %10s\n" $i ${sid[$i]}
                                                i=`expr $i + 1`
                                        done
                                        echo ""
                                        echo "Select the Oracle SID with given number [1]:"
                                        read entry
                                        if [ -n "$entry" ]
                                        then
                                                entry=`echo "$entry" | sed "s/[a-z,A-Z]//g"`
                                                if [ -n "$entry" ]
                                                then
                                                        entry=`expr $entry`
                                                        if [ $entry -ge 1 ] && [ $entry -le $sid_available ]
                                                        then
                                                                sid_selected=$entry
                                                        fi
                                                fi
                                                else
                                                sid_selected=1
                                        fi
                                esac
                        done
                        #
                        # SET ORACLE_SID
                        #
                        export ORACLE_SID=${sid[$sid_selected]}
                        echo "Your profile configured for $ORACLE_SID with information below:"
                        echo ""
                        export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/bin
                        unset LD_LIBRARY_PATH
                        ORAENV_ASK=NO
                        . oraenv
                        alias oh="cd ${ORACLE_HOME}"
                        ora_version=`echo $ORACLE_HOME | awk 'BEGIN {FS="/"} ; {print $6}' | awk 'BEGIN {FS="."} ; {print $1}'`
                        if [ $ora_version -lt 11 ]
                        then
                        alias bdump="cd /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump"
                        alias talert="tail -f /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        alias valert="view /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        fi
                        if [ $ora_version -ge  11 ]
                        then
                        export ORACLE_UNQNAME=$ORACLE_SID
                        alias talert='tail -f $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias valert='view $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias alasm='cd $ORACLE_BASE/`adrci exec="show homes" | grep ASM`/trace'
                        alias bdump='cd $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace'
                        fi
                        alias pmon='ps -fu oracle | grep pmon | grep -v grep'
                        alias tns='ps -fu oracle | grep tns | grep -v grep'
                        alias oradiag='cd $ORACLE_BASE/diag/'
                        alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'
                        unset ORAENV_ASK
                        echo
                        #
                        #GIVE MESSAGE
                        #
                        else
                        echo "No entries in $ORATAB. no environment set"
                fi
        fi
fi
}




stty erase "^?"
stty erase "^H"


[oracle@wcp12cr2 ~]$

[oracle@wcp12cr2 ~]$ alias alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias sys='sqlplus "/ as sysdba"' alias vi='vim' alias vmctl='/oracle/scripts/vmctl.sh' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [oracle@wcp12cr2 ~]$








export ORACLE_BASE=/opt/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/12.2.0/db_1
export ORACLE_PATH=$ORACLE_BASE/dba_scripts/common/sql:.:$ORACLE_HOME/rdbms/admin
export ORACLE_SID=vihaan
export PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
export PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH=${PATH}:$ORACLE_BASE/dba_scripts/common/bin
export ORACLE_TERM=xterm
export TNS_ADMIN=$ORACLE_HOME/network/admin
export ORA_NLS10=$ORACLE_HOME/nls/data
export NLS_DATE_FORMAT="DD-MON-YYYY HH24:MI:SS"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export CLASSPATH=$ORACLE_HOME/JRE
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
export CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export THREADS_FLAG=native
export TEMP=/tmp
export TMPDIR=/tmp

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


cat .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs
export TMOUT=
export ORACLE_BASE=/u01/app/oracle
#export ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/dbhome_1
export ORACLE_SID=ibrac1

export GG_HOME=/dumps/gghome_capture
export LD_LIBRARY_PATH=$GG_HOME:$ORACLE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

PATH=$ORACLE_HOME/bin:$ORACLE_HOME/OPatch:$GG_HOME:$PATH:$HOME/.local/bin:$HOME/bin

export PATH


echo " -MGMTDB /u01/app/12.2.0/grid "
echo " +ASM1   /u01/app/12.2.0/grid "
echo " ibrac1  /u01/app/oracle/product/12.2.0/dbhome_1 "
echo " capture /u01/app/oracle/product/12.1.0/dbhome_1 "
echo "  "
echo "  "
echo "  "
echo "  "

EDITOR=vi
SQLPATH=/home/oracle/dba
export PATH EDITOR SQLPATH

export ORACLE_PATH=/home/oracle/dba/






setsid ()
{
unset ORATAB
unset ORACLE_BASE
unset ORACLE_HOME
unset ORACLE_SID
ORACLE_BASE=/u01/app/oracle
ORATAB=/etc/oratab
if tty -s
then
        if [ -f $ORATAB ]
        then
                line_count=`cat $ORATAB | grep -v ^# | sed 's/:.*//' | wc -l`
                # check that the oratab file has some contents
                if [ $line_count -ge 1 ]
                        then
                        sid_selected=0
                        while [ $sid_selected -eq 0 ]
                        do
                                sid_available=0
                                for i in `cat $ORATAB | grep -v ^# | sed 's/:.*//'`
                                        do
                                        sid_available=`expr $sid_available + 1`
                                        sid[$sid_available]=$i
                                        done
                                # get the required SID
                                case ${SETSID_AUTO:-""} in
                                        YES) # Auto set use 1st entry
                                        sid_selected=1 ;;
                                        *)
                                        i=1
                                        while [ $i -le $sid_available ]
                                        do
                                                printf "%2d- %10s\n" $i ${sid[$i]}
                                                i=`expr $i + 1`
                                        done
                                        echo ""
                                        echo "Select the Oracle SID with given number [1]:"
                                        read entry
                                        if [ -n "$entry" ]
                                        then
                                                entry=`echo "$entry" | sed "s/[a-z,A-Z]//g"`
                                                if [ -n "$entry" ]
                                                then
                                                        entry=`expr $entry`
                                                        if [ $entry -ge 1 ] && [ $entry -le $sid_available ]
                                                        then
                                                                sid_selected=$entry
                                                        fi
                                                fi
                                                else
                                                sid_selected=1
                                        fi
                                esac
                        done
                        #
                        # SET ORACLE_SID
                        #
                        export ORACLE_SID=${sid[$sid_selected]}
                        echo "Your profile configured for $ORACLE_SID with information below:"
                        echo ""
                        export PATH=/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/bin
                        unset LD_LIBRARY_PATH
                        ORAENV_ASK=NO
                        . oraenv
                        alias oh="cd ${ORACLE_HOME}"
                        ora_version=`echo $ORACLE_HOME | awk 'BEGIN {FS="/"} ; {print $6}' | awk 'BEGIN {FS="."} ; {print $1}'`
                        if [ $ora_version -lt 11 ]
                        then
                        alias bdump="cd /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump"
                        alias talert="tail -f /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        alias valert="view /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log"
                        fi
                        if [ $ora_version -ge  11 ]
                        then
                        export ORACLE_UNQNAME=$ORACLE_SID
                        alias talert='tail -f $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias valert='view $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'
                        alias alasm='cd $ORACLE_BASE/`adrci exec="show homes" | grep ASM`/trace'
                        alias bdump='cd $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace'
                        fi
                        alias pmon='ps -fu oracle | grep pmon | grep -v grep'
                        alias tns='ps -fu oracle | grep tns | grep -v grep'
                        alias oradiag='cd $ORACLE_BASE/diag/'
                        alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'
                        unset ORAENV_ASK
                        echo
                        #
                        #GIVE MESSAGE
                        #
                        else
                        echo "No entries in $ORATAB. no environment set"
                fi
        fi
fi
}

setsid


showsid()
{
echo ""
echo "ORACLE_SID=$ORACLE_SID"
echo "ORACLE_BASE=$ORACLE_BASE"
echo "ORACLE_HOME=$ORACLE_HOME"
echo "alias oh=cd ${ORACLE_HOME}"
echo "alias pmon='ps -fu oracle | grep pmon | grep -v grep'"
echo "alias tns='ps -fu oracle | grep tns | grep -v grep'"
ora_version=`echo $ORACLE_HOME | awk 'BEGIN {FS="/"} ; {print $6}' | awk 'BEGIN {FS="."} ; {print $1}'`
if [ $ora_version -ge  11 ]
then
echo "alias talert='tail -f $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'"
echo "alias valert='view $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace/alert_${ORACLE_SID}.log'"
echo "alias bdump='cd $ORACLE_BASE/`adrci exec="show homes" | grep $ORACLE_SID`/trace'"
echo "alias alasm='cd $ORACLE_BASE/`adrci exec="show homes" | grep ASM`/trace'"
echo "alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'"
echo "alias oradiag='cd $ORACLE_BASE/diag/'"
fi
if [ $ora_version -lt 11 ]
then
echo "alias bdump=cd /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump"
echo "alias talert=tail -f \"/u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log\""
echo "alias valert=\"view /u01/app/oracle/admin/${ORACLE_SID//[!A-Za-z]}/bdump/alert_${ORACLE_SID}.log\""
echo "alias ldiag='cd $ORACLE_BASE/diag/tnslsnr/'"
fi
echo ""
}

showsid





function _gp ()
{
    SetIt=0;
    [ "$1" == "1" ] && [ ${#PWD} -gt $[COLUMNS-60] ] && SetIt=1;
    [ "$1" == "2" ] && [ ${#PWD} -lt $[COLUMNS-60+1] ] && SetIt=1;
    if [ "$SetIt" == "1" ]; then
        IsGit=0;
        GitDir="$PWD";
        while [ ${#GitDir} -gt 1 ] && [ "$IsGit" == "0" ]; do
            if [ -d "$GitDir/.git" ] && [ ! -e "$GitDir/.git/nawakom" ]; then
                IsGit=1;
            else
                GitDir=${GitDir%/*};
            fi;
        done;
        if [ "$IsGit" = "1" ]; then
            TmpStr="$(< "$GitDir/.git/HEAD")";
            TmpStr="${TmpStr##* }";
            TmpStr="${TmpStr/refs\/heads\//}";
            TrimedGitDir=${GitDir//\/}
                        NbLevels=$(expr ${#GitDir} - ${#TrimedGitDir})
            if [ ${NbLevels} -eq 1 ]; then
              Niveau1=$(dirname ${GitDir#${GitDir%/*}});
                        else if  [ ${NbLevels} -eq 2 ]; then
                 Niveau1=$(dirname ${GitDir#${GitDir%/*/*}});
                          else
                Niveau1=$(dirname ${GitDir#${GitDir%/*/*/*}});
                   fi
                        fi
            Niveau2_2=${GitDir##*/};
            Niveau2_1=${PWD/$GitDir/};
            GitDirX="$PWD";
            [ "$1" == "1" ] && builtin echo -e "\001\e[43m\e[30m\002 \001\xEE\002\x83\xAA ${Niveau1}/\001\e[31m\002${GitDir##*/}\001\e[30m\002${Niveau2_1} \001\e[41m\e[33m\002\001\xEE\x82\002\xB0\001\e[30m\002 \001\xEE\x82\002\xA0 $TmpStr \001\e[0m\e[31m\002\001\xEE\x82\002\xB0\001\e[m\e[0m\002\001\xEE\x82\002\xB0 ";
            [ "$1" == "2" ] && builtin echo -e "\001\e[43m\002\001\xEE\x82\002\xB0\001\e[30m\002 \001\xEE\002\x83\xAA ${Niveau1}/\001\e[31m\002${Niveau2_2}\001\e[30m\002${Niveau2_1} \001\e[41m\e[33m\002\001\xEE\x82\002\xB0\001\e[30m\002 \001\xEE\x82\002\xA0 $TmpStr \001\e[0m\e[31m\002\001\xEE\x82\002\xB0 ";
        else
            [ "$1" == "1" ] && builtin echo -e "\001\e[43m\e[30m\002 \001\xEE\002\x83\xAA ${PWD#${PWD%/*/*/*}/} \001\e[0m\e[0m\e[33m\002\001\xEE\x82\002\xB0\001\e[m\e[0m\002\001\xEE\x82\002\xB0 ";
            [ "$1" == "2" ] && builtin echo -e "\001\e[43m\002\001\xEE\x82\002\xB0\001\e[30m\002 \001\xEE\002\x83\xAA ${PWD#${PWD%/*/*/*}/} \001\e[m\e[0m\e[33m\002\001\xEE\x82\002\xB0 ";
        fi;
    fi
}

export PS1='$(_gp 1)$(_gp 2)\e[37m'



# If id command returns zero, you got root access.
if [ $(id -u) -eq 0 ];
then # you are root, set red colour prompt
  PS1="\\[$(tput setaf 1)\\]\\u@\\h:\\w #\\[$(tput sgr0)\\]"
else # normal
  PS1="[\\u@\\h:\\w] $"
fi


alias sqlme='sqlplus / as sysdba'



Oracle DBA

anuj blog Archive