Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

su - oracle logout 1

Status
Not open for further replies.
Mar 31, 2004
151
US
When I try to su - oracle from a script, it is automatically logging out. I debugged using set -x and can see "logout". Any ideas?

The following script always prints root

su - oracle 2>/dev/null
echo `whoami`
 
Take a look at the .profile in the oracle's home directory.
Do a [tt] grep oracle /etc/passwd [/tt] to discover the directory name.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks for the response.

oracle .profile is:

It looks normal. Is it the trap statement?

Code:
# Set up the terminal:
        if [ "$TERM" = "" ]
        then
                eval ` tset -s -Q -m ':?hp' `
        else
                eval ` tset -s -Q `
        fi
        stty erase "^H" kill "^U" intr "^C" eof "^D"
        stty hupcl ixon ixoff
        tabs
 
# Set up the search paths:
        PATH=$PATH:.
 
# Set up the shell environment:
        set -u
        trap "echo 'logout'" 0 ########################## trap
 
# Set up the shell variables:
        EDITOR=vi
        export EDITOR
# Set up the shell environment: set -u trap "echo 'logout'" 0
        umask 022
ORACLE_HOME=/u01/app/oracle/product/8.1.7; export ORACLE_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_SID=oraca; export ORACLE_SID
PATH=:$PATH:.:/opt/perl5/bin:/opt/gcc/bin:/opt/softbench/bin:$ORACLE_HOME/bin:/bin:opt/bin:/opt/softbench/contrib/bin:/opt/e
macs/bin:
 
SHLIB_PATH=$ORACLE_HOME/lib:/usr/lib/Motif1.2:/usr/lib; export SHLIB_PATH
##
##
## Data Guard variables
##
export DATAGUARD_ID=1000
 
I guess the culprit is set -u
BTW, if the logging shell is a standard bourne shell, then this line is in error:
export DATAGUARD_ID=1000

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks. I commented them out both and still got the same problem.

It started printing a new error with the original .profile

su - oracle
stty: : Not a typewriter

< Copyright messages ....>

You have mail.
stty: : Not a typewriter
stty: : Not a typewriter
logout
+ whoami
+ echo root
root
 
stty: : Not a typewriter
Usually this error is raised when the standard input is redirected.
You may add a set -x command in this .profile and in /etc/profile.
BTW, what is the login shell of the user oracle ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
The login shell is sh /usr/bin/sh

There is this source line at the end of oracle .profile (after the export DATAGUARD statement):

# Set up HBF run-time environment
. ./dmeenv.sh

./dmeenv.sh is

Code:
PS1="[`whoami`@`hostname`] $ "
# *****************************************************************************
# Define dme environment variables
# dmeBIN - executables
# dmeLIB - 3rd party libraries
# dmeCMD - shell scripts
# dmePID - process IDs
# *****************************************************************************
if [ -d /u01/app/dme/bin ]
then
    export dmeBIN=/u01/app/dme/bin
else
    echo "dmeBIN:/u01/app/dme/bin does not exist.\n"
fi
 
if [ -d /u01/app/lib ]
then
    export dmeLIB=/u01/app/dme/lib
else
 echo "dmeLIB:/u01/app/dme/lib does not exist.\n"
fi
 
if [ -d /home/cmds ]
then
    export dmeCMD=/home/cmds
else
    echo "dmeCMD:/home/cmds does not exist.\n"
fi
 
if [ -d /home/cmds/pid ]
then
    export dmePID=/home/cmds/pid
else
    echo "dmePID:/home/cmds/pid does not exist.\n"
fi
# *****************************************************************************
# Define and verify other environment variables
# JAVA_HOME is required for executing all server programs
# *****************************************************************************
if [ -d /opt/java1.3/jre ]
then
    export JAVA_HOME=/opt/java1.3
    export PATH=$PATH:$JAVA_HOME/jre/bin
    export SHLIB_PATH=$SHLIB_PATH:$JAVA_HOME/jre/lib/PA_RISC:$JAVA_HOME/jre/lib/PA_RISC/classic
else
    echo "JAVA_HOME:Java installation does not exist on /opt/java1.3\n"
fi

And this is the total output:

Code:
You have mail.
+ [ vt100 =  ]
+ tset -s -Q
+ eval export TERM; TERM=vt100;
+ export TERM
+ TERM=vt100
+ stty erase ^H kill ^U intr ^C eof ^D
stty: : Not a typewriter
+ stty hupcl ixon ixoff
stty: : Not a typewriter
+ tabs
+ PATH=/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/fc/bin:/
opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X11
:/opt/hparray/bin:/opt/omni/bin:/opt/graphics/common/bin:.
+ set -u
+ trap echo 'logout' 0
+ EDITOR=vi
+ export EDITOR
+ umask 022
+ ORACLE_HOME=/u01/app/oracle/product/8.1.7
+ export ORACLE_HOME
+ ORACLE_BASE=/u01/app/oracle
+ export ORACLE_BASE
+ ORACLE_SID=oraca
+ export ORACLE_SID
+ PATH=:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/fc/bin:
/opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X1
1:/opt/hparray/bin:/opt/omni/bin:/opt/graphics/common/bin:.:.:/opt/perl5/bi
n:/opt/gcc/bin:/opt/softbench/bin:/u01/app/oracle/product/8.1.7/bin:/bin:op
t/bin:/opt/softbench/contrib/bin:/opt/emacs/bin:
+ SHLIB_PATH=/u01/app/oracle/product/8.1.7/lib:/usr/lib/Motif1.2:/usr/lib
+ export SHLIB_PATH
+ export DATAGUARD_ID=aaaa
+ . ./dmeenv.sh
+ + whoami
+ hostname
PS1=[oracle@demserv] $ 
+ [ -d /u01/app/dme/bin ]
+ export dmeBIN=/u01/app/dme/bin
+ [ -d /u01/app/lib ]
+ export dmeLIB=/u01/app/dme/lib
+ [ -d /home/cmds ]
+ export dmeCMD=/home/cmds
+ [ -d /home/cmds/pid ]
+ export dmePID=/home/cmds/pid
+ [ -d /opt/java1.3/jre ]
+ export JAVA_HOME=/opt/java1.3
+ export PATH=:/usr/bin:/usr/ccs/bin:/usr/contrib/bin:/opt/nettladm/bin:/opt/fc/bin:
/opt/fcms/bin:/opt/upgrade/bin:/opt/pd/bin:/usr/bin/X11:/usr/contrib/bin/X1
1:/opt/hparray/bin:/opt/omni/bin:/opt/graphics/common/bin:.:.:/opt/perl5/bi
n:/opt/gcc/bin:/opt/softbench/bin:/u01/app/oracle/product/8.1.7/bin:/bin:op
t/bin:/opt/softbench/contrib/bin:/opt/emacs/bin::/opt/java1.3/jre/bin
+ export SHLIB_PATH=/u01/app/oracle/product/8.1.7/lib:/usr/lib/Motif1.2:/usr/lib:/op
t/java1.3/jre/lib/PA_RISC:/opt/java1.3/jre/lib/PA_RISC/classic
+ echo logout
logout
+ whoami
+ echo root
root

 
So, as the export name=value is valid, /usr/bin/sh should be a korn shell or a bash (linux).
Have you some .*rc files in the oracle's home directory ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
yes

.cshrc is:

Code:
#
# Default user .cshrc file (/usr/bin/csh initialization).
 
# Usage:  Copy this file to a user's home directory and edit it to
# customize it to taste.  It is run by csh each time it starts up.
 
# Set up default command search path:
#
# (For security, this default is a minimal set.)
 
        set path=( $path )
 
# Set up C shell environment:
 
        if ( $?prompt ) then            # shell is interactive.
            set history=20              # previous commands to remember.
            set savehist=20             # number to save across sessions.
            set system=`hostname`       # name of this system.
            set prompt = "$system \!: " # command prompt.
 
            # Sample alias:
 
            alias       h       history
 
            # More sample aliases, commented out by default:
 
            # alias     d       dirs
            # alias     pd      pushd
            # alias     pd2     pushd +2
            # alias     po      popd
            # alias     m       more
        endif
~

.exrc is:

Code:
set autoindent autowrite showmatch wrapmargin=0 report=1
map  ^W   :set wrapmargin=8
map  ^X   {!}sort -b
map  ^[h  1G
map  ^[H  1G
map  ^[F  G
map  ^[V  ^B
map  ^[U  ^F
map  ^[T  ^Yk
map  ^[S  ^Ej
map  ^[Q   i
map  ^[P   x
map  ^[L   O
map  ^[M   dd
map  ^[K   D
map  ^[J   DjdG$
map! ^[A  ^[ka
map! ^[D  ^[ha
map! ^[C  ^[la
map! ^[B  ^[ja
map! ^[L  ^M
map! ^[Q  ^[
map! ^[R  ^[
 
.cshrc is for C-shell
.exrc is for vi
BTW, instead of who am i, try id, as who am i gives the login name, not the effective user name.


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top