0

I have installed Oracle 11gR2 and want to connect with SQL*Plus but I can't.

I login in as root and then switch user to oracle as

su oracle

I have added required Oracle environment variables in .bash_profile but it is not executed when i switch to oracle user from root. Even executing the bash file manually does not export the variables using following command

$ ./.bash_profile

These are the contents of my .bash_profile:

#!/bin/bash 
#.bash_profile

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

# User specific environment and startup programsotp
PATH=$PATH:$HOME/bin

export PATH

# Oracle Settings
TMP=/tmp; export TMP 
TMPDIR=$TMP; export TMPDIR 

ORACLE_HOSTNAME=orcl.genie.com; export ORACLE_HOSTNAME
ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME 
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE 
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME 
ORACLE_SID=orcl; export ORACLE_SID 
ORACLE_TERM=xterm; export ORACLE_TERM 
PATH=$ORACLE_HOME/bin:/usr/sbin:$PATH; export PATH 

LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH 
CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH 

if [ $USER = "oracle" ]; then 
   if [ $SHELL = "/bin/ksh" ]; then 
      ulimit -p 16384 
      ulimit -n 65536 
   else 
      ulimit -u 16384 -n 65536 
   fi 
fi 

umask 022
Ahmad Raza
  • 39
  • 10
  • "I can't" isn't helpful - you haven't said how you try to connect or what happens when you do, including any errors you get. – Alex Poole Feb 03 '16 at 10:21
  • when i try to connect as sqlplus / as sysdba bash: sqlplus: command not found – Ahmad Raza Feb 03 '16 at 10:27
  • Are you running in a [login shell](http://stackoverflow.com/a/416931/266304)? Can you debug that the .bash_profile is actually being run (e.g. stick some echo/printf commands in there to see what's displayed)? If it is being run what does `env` show for the variables you're setting? – Alex Poole Feb 03 '16 at 10:37
  • How to check if i am running in a login shell? Even running without login shell, why is it not executing when i am manually running .bash_profile as sh ./.bash_profile – Ahmad Raza Feb 03 '16 at 11:03
  • For the manual step you just added you have to source the file: `. ./.bash_profile`. – Alex Poole Feb 03 '16 at 11:03
  • Thanks a lot. saved my day buddy. :) – Ahmad Raza Feb 03 '16 at 11:09

1 Answers1

0

To check if you are running in a login shell, use the following command

shopt login_shell

if it displays

login_shell off 

then you are not running in a login shell. You need to switch to oracle user with -l switch

su -l oracle

Hope, it solves your problem.

FarIDM
  • 109
  • 6