Input to shell script

Hi,
I have 10 database instances runnning in one unix box. To connect to each database..i have to set the environment. I am trying to write a shell script to set my environment for database by just tying the oracle instance name

After logging into the unix machine... i want to type the oracle instacne name and the environment needs to be set for the typed oracle instance

How to pass an oracle instance name typed in the console to the shell script

any idea? how to do this

Is there any other way to do?

$/u01/oracle/ORACLEINSTANCENAME

Script:

FILE_LOCATION=/etc/oratab

dbname=awk 'BEGIN{FS=":"}{print $1}' < "$FILE_LOCATION" )
do
#echo "USER #$n = $dbname"
echo $dbname
if [$dbname= passed_db_name]
export ORACLE_SID=dbname
done

Many Thanks,

I'm not sure I'm following you a 100% but here is what I think your trying to do. You can manual call this script or put it in your .profile so it starts when you log in. Hope this helps.

#!/bin/ksh
FILE_LOCATION=/etc/oratab

cat $FILE_LOCATION | awk -F: '{print $1}'
print "Chose instance to set environment"
read option

case $option in
"first_instance")
export ORACLE_SID=first_instance;;
"second_instance")
export ORACLE_SID=second_instance;;
"third_instance")
export ORACLE_SID=third_instance;;
esac
print "ORACLE_SID=$option"
exit

Thanks for the script....

What i am looking for is... after loging to unix machine if i type type the instance name and it has to set the oracle environment.

Many thanks,

Not sure if I understand exactly what you are trying to do, but if you want a single script to run to set the environment for any of your 10 Oracle instances then how about something like:

#!/bin/ksh
FILE_LOCATION=/etc/oratab
INSTANCE=$1
export ORACLE_SID=$INSTANCE
export any other variables, path etc evaluated from parameter or 
  conditional e.g. case statement setting values depending on the
  instance name...
Print "Environment set for $INSTANCE"

To get variables into the environment you need to source (run using the syntax <dot><space><scriptname>) the script (called 'oracle' in the example below) and pass the instance name as a parameter. It's up to you what (if any) validation you need to ensure that the database name is valid.

. ./oracle live