awk/sed script to read values from parameter files

Hi,

I am writing a shell program that executes a lot of Oracle SQL Files on different databases based on the enviroment setting value. I am trying to design a parameter file where i can store the environment values for all the databases in the below format

Environment File

File Name oraenv

# /* DB1 /
ORACLE_SID=DB1
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /
End /
# /
DB2 /
ORACLE_SID=DB2
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /
End /
# /
DB3 /
ORACLE_SID=DB3
ORACLE_BASE=
ORACLE_HOME=
PATH=
LD_LIBRARY_PATH=
.
.
Other Parameters
# /
End */

Master Script <-- Main Program that uses these parameters

File Name actions.sh

When the script is executed as ./actions,sh DB1 i want this to read all the parameters related to DB1 from the oraenv written between the pattern below
# /* DB1 /
.
...
..
# /
End */

create "export ORACLE_SID .." etc...

Any ideas of how best we can do this....

Thanks and Kind Regards,
Rajan.S

You could do something like for example:

DB=DB1
for LINE in `sed -n '/ '${DB}' /,/ End /p' infile| grep -v ^#`; do
     export "${LINE}"
done

Where instead of variable DB you can use $1 for input.

Some of my parameters have space any idea how i can get round them since for loop treats space as a new line

Quote the command:

for LINE in "`sed -n '/ '${DB}' /,/ End /p' infile| grep -v ^#`"; do

Regards

Thanks a lot everyone for the help it worked fine

One issue that i am facing with the above code is if i have the following line in my parameter file like

Parameter File content

infile

# /* DB1 /
ORACLE_HOME=/temp
OH=$ORACLE_HOME
# /
End */

The below command

for LINE in `sed -n '/ '${DB}' /,/ End /p' infile| grep -v ^#`; do
export "${LINE}"
done

works great when it reads line one that is ORACLE_HOME is set to /temp
but i expect it to set OH=/temp also but OH gets set to $ORACLE_HOME.Basically it does not translate the $sign read from the parameter file. Any ideas please

I was able to get through this issue using the eval option

for LINE in \`sed -n '/ '$\{DB\}' /,/ End /p' infile| grep -v ^\#\`; do
    eval \`echo "export " $\{LINE\}\`
done

Thanks
Rajan