Operating System - HP-UX
1833653 Members
3621 Online
110062 Solutions
New Discussion

Re: How to get oracle user's environment parameter in unix shell script

 
Chinese Feng
Regular Advisor

How to get oracle user's environment parameter in unix shell script

If i run a unix shell script by user root , in this script i want to get user oracle's environment parameter "ORACLE_SID"'s value , how to implement it , thanks!

 

 

P.S.This thread has been moved from HP-UX>System Administration to HP-UX > languages- HP Forums Moderator

Franky
11 REPLIES 11
Stephan.
Honored Contributor

Re: How to get oracle user's environment parameter in unix shell script

Hi,
ORACLE_SID is usually defined in the '.profile' of the oracle user.

If you only want to use it in one script just copy it out of the profile into the script, or set it inside the script.

ORACLE_SID=123

To set it permanently for root you can add it to the .profile from root.
Chinese Feng
Regular Advisor

Re: How to get oracle user's environment parameter in unix shell script

Thanks for your answer.
But if i don't know where is the .profile exist. and i can use command "su - oracle" and "env | grep -i ORACLE_SID" to get the parameter, but i don't know how to write this kind of shell script.
Franky
Stephan.
Honored Contributor

Re: How to get oracle user's environment parameter in unix shell script

Where is the script you want run?

Open it with vi and insert a line

ORACLE_SID=

Save the script and run it as root.

hth
Vijaykumar_1
Valued Contributor

Re: How to get oracle user's environment parameter in unix shell script

Hi,

.profile file exists in every users home directory.Immediately when u login it takes you to the home directory by default.

These files are hidden files and are not visible with ls command. Hence you need to apply ls -la..

2 -r-------- 1 root sys 40 Jan 7 2008 .exrc
2 -r--r--r-- 1 bin bin 334 Nov 14 2000 .login
2 -rw-r----- 1 root sys 789 May 16 2007 .nvdrc
4 -rw------- 1 bin bin 1200 Mar 30 2007 .profile
Chinese Feng
Regular Advisor

Re: How to get oracle user's environment parameter in unix shell script

My problem is i don't know how to switch to user oracle and how to back to user root. I use below script:
"
su - oracle
oracle_sid=`env|grep -i SID`
exit
"
but i can't switch to user root again.


Same problem , i'm not sure where is the ORACLE_HOME directory .
Franky
Stephan.
Honored Contributor

Re: How to get oracle user's environment parameter in unix shell script

>>My problem is i don't know how to switch to user oracle and how to back to user root

Press 'CTRL' 'D'

>>Same problem , i'm not sure where is the ORACLE_HOME directory .

# su - oracle
$ env | grep -E 'ORACLE_SID|ORACLE_HOME'
$
#
Chinese Feng
Regular Advisor

Re: How to get oracle user's environment parameter in unix shell script

how to type "CTRL" "D" in shell script?
Franky
V. Nyga
Honored Contributor

Re: How to get oracle user's environment parameter in unix shell script

Hi,

try 'logout'

V.
*** Say 'Thanks' with Kudos ***
Stephan.
Honored Contributor

Re: How to get oracle user's environment parameter in unix shell script

It seems i don't get it right.

Try this:

su - oracle
env | grep -E 'ORACLE_SID|ORACLE_HOME'
exit

Chinese Feng
Regular Advisor

Re: How to get oracle user's environment parameter in unix shell script

Can't exit.

Nobody do this kind task like that.

"switch user in shell script"

:(
Franky
Dennis Handly
Acclaimed Contributor

Re: How to get oracle user's environment parameter in unix shell script

su - oracle -c "env | grep -e ORACLE_SID -e ORACLE_HOME"