I have created choice script at oracle login as i have inistalled 2 versions of oracle on the server
1 is for oracle 10g
2 is for oracle 11g
When i use su - oracle
It displays like this
1) DATABASE 10g
2) DATABASE 11g
But at the time of backup throgh shell script how can i pass values 1 & 2
Please provide me syntax as
su - oracle parameter to chose oracle 10g or oracle 11g in shell script.
echo " Please connect database"
echo " "
echo " 1 --> DATABASE 10g "
echo " 2 --> DATABASE 10g "
echo " "
case $OPTION in
ORACLE_SID=DATABASE 10g;export ORACLE_SID
ORACLE_SID=DATABASE 11g;export ORACLE_SID
example for bat file
Look only scripts
As you see in bat file you can set or export ORACLE variables.
As i mentioned we are using AIX
& after su - oracle we have enter the choice 1 or 2
my question is how can i pass 1 or 2 in below script.
export ORACLE_SID is already set in choice, just want to pass values 1 or 2 in below script
su - oracle -c /apps/oracle/dbbackup.sh
I know selecting choice 1 or 2 are simple shell scripting options. I will suggest using crontab to schedule backups.
12 * * * * su - oracle -c /apps/oracle/dbbackup1.sh > /apps/oracle/dbbackup1.log
11 * * * * su - oracle -c /apps/oracle/dbbackup2.sh > /apps/oracle/dbbackup2.log
Have different HOME & SID in each script.
I would consider the concept of your 'logon script' itself to be flawed. As you have discovered, it forces any connecting session to be interactive, and to what end? Suppose I log on and make a selection, then once logged on and the environment set for that that selection, I need to work with the other database? How do you get the environment reset at that point? Surely you don't log off and log back on just so you can take the other choice from your logon script.
Bottom line, I'd lose that script and learn to use the oracle-supplied utility 'oraenv'. When you do that, your posted problems disappears.
You can use the if statement in your shell pass the option 1 or 2(or 10g /11g) as per the option set your Environment variable there.
and then you can use your script like
su - oracle -c /apps/oracle/dbbackup.sh 10g
su - oracle -c /apps/oracle/dbbackup.sh 11g
Add something like that in your existing script
if [[ env_opt == 11g ]] ; then
if [[ env_opt == 10g ]] ; then
I have to agree with Ed on the idea on having a logon script for the Oracle user. We have such a script for end users but it sets the Oracle environment and invokes the application for the customer. Only DBA's should be using the Oracle account and a DBA should just be able to invoke oraenv or a local script to set the Oracle account environment for the version of Oracle you want to connect to.
I can remember installing Oracle years ago on VMS and one of the first requirements listed in the Installation manual was to unset all environment variables before invoking the installer. A script like the can actually cause way more trouble than benefit in some cases.
IMHO -- Mark D Powell --