Sponsored Content
Top Forums Shell Programming and Scripting Set Oracle Environmental Variable !! Post 99478 by uuser on Friday 17th of February 2006 01:25:27 PM
Old 02-17-2006
Set Oracle Environmental Variable !!

Can someone send me a shell script to set all Oracle environment variable which is working.

I have the following script which works but not 100%. Please advice what you think is wrong.

Code:
if [ -t 0 ]                             # Command executed from a terminal
then
        ORACLE_SID=""
        while [ -z "${ORACLE_SID}" ]
        do
                tput clear; tput rev
                echo "Valid Oracle SIDs are :"
                tput rmso
                for SID in `cat /etc/oratab|grep -v "^#"|cut -f1 -d: -s`
                do
                        echo "                  ${SID}"
                done
                DEFAULT=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
                echo "\nEnter the Oracle SID you require (def: $DEFAULT): \c"
                read ANSWER
                [ "${ANSWER}" = "" ] && ANSWER=$DEFAULT
                export ORACLE_SID=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f1 -s`
                export ORACLE_HOME=`grep "^${ANSWER}:" /etc/oratab|cut -d: -f2 -s`
                if [ "${ORACLE_SID}" = "" ]
                then
                        echo "\n\n              ${ANS}: Invalid Oracle SID  \c"
                        sleep 2
                fi
        done
else                                    # Set to first entry in oratab
        export ORACLE_SID=`cat /etc/oratab|grep -v "^#"|cut -d: -f1 -s|head -1`
        export ORACLE_HOME=`cat /etc/oratab|grep -v "^#"|cut -d: -f2 -s|head -1`
fi

export ORACLE_SID=$ORACLE_SID
export ORACLE_HOME=$ORACLE_HOME
export PATH=${PATH}:${ORACLE_HOME}/bin
#ORAENV_ASK=NO
#. ${ORACLE_HOME}/bin/oraenv
#ORAENV_ASK=
echo
echo Oracle SID is now `tput rev`$ORACLE_SID`tput rmso`, Oracle Home is `tput rev`$ORACLE_HOME`tput rmso`
echo


When I run it it works as follows..
./setenv.sh
HTML Code:
Valid Oracle SIDs are :
                        mdmop
                        mdmt
                        mdmp

Enter the Oracle SID you require (def: mdmop): mdmt

Oracle SID is now mdmt, Oracle Home is /u001/app/oracle/product/9.2/home


 ga016dhd -> echo $ORACLE_SID
mdmop                                <== Not really set to mdmt(even if it said it is)
 ga016dhd -> echo $ORACLE_HOME
/u001/app/oracle/product/9.2/home
 [/home/oracle/script - oracle]

I think when the script executes it does execute export ORACLE_SID=$ORACLE_SID based on the values passed but once it is done executing the default values was set back ???? any reason why ??
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Environmental Variable

Hi, I'm exporting an environmental variable from a C program using putenv function. I'm calling the exe of the C program from shell script. But when I display the environmental variables from the Shell script, My varaible is not getting displayed. Can anyone please tell me how to get it in... (2 Replies)
Discussion started by: janemary.a
2 Replies

2. Shell Programming and Scripting

How to get the value of a variable which is having another value in environmental script?

Dear Folks, I am facing an issue in getting a value of a variable.Let me explain the scenario. I am having a list file say files.list in which I have mentioned 1 FILE1 2 FILE2 Then I am having an set_env.ksh in which I mentioned FILE1=/clocal/data/user/userdata.txt... (4 Replies)
Discussion started by: dinesh1985
4 Replies

3. Shell Programming and Scripting

Oracle environmental variables in shells script

Hi, Getting below error on executing the shell script which initiates sqlplus How to set oracle enviornment variables in the shell script ? With Regards (3 Replies)
Discussion started by: milink
3 Replies

4. UNIX for Dummies Questions & Answers

SQL loader script - ORACLE environmental variable

I am new in unix.. I am running a sql loader script where I have to specify the data file path but the file name contains spaces in it so giving error multiple arguments I have tried it with "" and '' but does n't work the command is : $ORACLE_HOME/bin/sqlldr... (1 Reply)
Discussion started by: Sandip Dey
1 Replies

5. Shell Programming and Scripting

Setting Environmental Variable

I have a request from a programmer to set an env variable for him. I know how to do it for bash shell by adding the following line to .bash_profile export $VAR=/home/code/project/ But this will be applicable only when he is in his bash shell. What is the procedure to be followed to make... (2 Replies)
Discussion started by: Tuxidow
2 Replies

6. UNIX for Advanced & Expert Users

Environmental variable

i want to set environmental variables in solaris and redhat. it should show the current directory and the default shell should be bourne shell. along with it should show the hostname.. like this hostname{/home/vipin/data}# ifconfig Thanks in advanced.:wall: Please use code tags.... (1 Reply)
Discussion started by: vipinkumarr89
1 Replies

7. Shell Programming and Scripting

set oracle variable in function

Hi, I have a function that is suposed to generate a AWR report: #-----------------------# gen_awr() #-----------------------# { sqlplus -s admin/admin@OCEAN11<<ENDOFSQL define num_days = '' define report_type = "html" define begin_snap =$snap1 define end_snap =%snap2 define... (1 Reply)
Discussion started by: amitlib
1 Replies

8. Shell Programming and Scripting

Clearing a environmental variable

i set a variable from the command line: export GANG="james,roy,martin" i can access this variable ($GANG) from a script. but each time i run the script, the variable keeps getting bigger. more info keeps getting added to it. Is there anyway i can make the $GANG variable contain the... (3 Replies)
Discussion started by: SkySmart
3 Replies

9. Shell Programming and Scripting

Issue with cron and environmental variable

My shell script it.sh.I am calling bip.sh from it.sh #!/bin/sh ORACLE_HOME=/var/opt/oracle/product/10g; export ORACLE_HOME PATH=$PATH:$ORACLE_HOME/bin:/bin:/usr/bin; export PATH today=`date "+%m-%d-%Y %H:%M:%S"`; export today CUR_DIR=$1; export CUR_DIR LOG_FILE=$CUR_DIR/error.log;... (4 Replies)
Discussion started by: rafa_fed2
4 Replies

10. Shell Programming and Scripting

<< Environmental Variables are not set when script completes >>

Hi Team, I have a wrapper script which i have pasted below, it internally calls one python script to generate Environmental in a file called /home/oracle/myenv.sh, when i execute this script via wrapper script, its not reflecting in my current session, still showing old env variables. any... (2 Replies)
Discussion started by: kamauv234
2 Replies
OCF_HEARTBEAT_ORALSN(7) 					OCF resource agents					   OCF_HEARTBEAT_ORALSN(7)

NAME
ocf_heartbeat_oralsnr - Manages an Oracle TNS listener SYNOPSIS
oralsnr [start | stop | status | monitor | meta-data | validate-all] DESCRIPTION
Resource script for Oracle Listener. It manages an Oracle Listener instance as an HA resource. SUPPORTED PARAMETERS
sid The Oracle SID (aka ORACLE_SID). Necessary for the monitor op, i.e. to do tnsping SID. (unique, required, string, no default) home The Oracle home directory (aka ORACLE_HOME). If not specified, then the SID should be listed in /etc/oratab. (optional, string, no default) user Run the listener as this user. (optional, string, no default) listener Listener instance to be started (as defined in listener.ora). Defaults to LISTENER. (unique, optional, string, no default) SUPPORTED ACTIONS
This resource agent supports the following actions (operations): start Starts the resource. Suggested minimum timeout: 120. stop Stops the resource. Suggested minimum timeout: 120. status Performs a status check. Suggested minimum timeout: 60. monitor Performs a detailed status check. Suggested minimum timeout: 30. Suggested interval: 10. validate-all Performs a validation of the resource configuration. Suggested minimum timeout: 5. meta-data Retrieves resource agent metadata (internal use only). Suggested minimum timeout: 5. methods Suggested minimum timeout: 5. EXAMPLE
The following is an example configuration for a oralsnr resource using the crm(8) shell: primitive p_oralsnr ocf:heartbeat:oralsnr params sid=string op monitor depth="0" timeout="30" interval="10" SEE ALSO
http://www.linux-ha.org/wiki/oralsnr_(resource_agent) AUTHOR
Linux-HA contributors (see the resource agent source for information about individual authors) resource-agents UNKNOWN 03/09/2014 OCF_HEARTBEAT_ORALSN(7)
All times are GMT -4. The time now is 02:51 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy