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
Session::Oracle(3)					User Contributed Perl Documentation					Session::Oracle(3)

NAME
Apache::Session::Oracle - An implementation of Apache::Session SYNOPSIS
use Apache::Session::Oracle; #if you want Apache::Session to open new DB handles: tie %hash, 'Apache::Session::Oracle', $id, { DataSource => 'dbi:Oracle:sessions', UserName => $db_user, Password => $db_pass, Commit => 1 }; #or, if your handles are already opened: tie %hash, 'Apache::Session::Oracle', $id, { Handle => $dbh, Commit => 1 }; DESCRIPTION
This module is an implementation of Apache::Session. It uses the Oracle backing store and no locking. See the example, and the documentation for Apache::Session::Store::Oracle for more details. USAGE
The special Apache::Session argument for this module is Commit. You MUST provide the Commit argument, which instructs this module to either commit the transaction when it is finished, or to simply do nothing. This feature is provided so that this module will not have adverse interactions with your local transaction policy, nor your local database handle caching policy. The argument is mandatory in order to make you think about this problem. This module also respects the LongReadLen argument, which specifies the maximum size of the session object. If not specified, the default maximum is 8 KB. AUTHOR
This module was written by Jeffrey William Baker <jwbaker@acm.org>. SEE ALSO
Apache::Session::File, Apache::Session::Flex, Apache::Session::DB_File, Apache::Session::Postgres, Apache::Session perl v5.12.1 2007-09-28 Session::Oracle(3)
All times are GMT -4. The time now is 11:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy