awk/sed Command : Parse parameter file / send the lines to the ksh export command

Sorry for the duplicate thread this one is similar to the one in
http://www.unix.com/shell-programming-scripting/88132-awk-sed-script-read-values-parameter-files.html\#post302255121

Since there were no responses on the parent thread since it got resolved partially i thought to open the new thread for the remaining issue

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...

Solution

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

The problem with the above code is some of the parameters in the oraenv file have $.. Like as below

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

Expected result is
ORACLE_HOME=/temp
OH=/temp

Actual results
ORACLE_HOME=/temp
OH=$ORACLE_HOME

I have been struggling to resolve this issue for 4 hrs now... Any quick help is very appreciated.

Any updates 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

Yeah, just use "eval export $LINE". You might need to do more with sed to strip any funny characters or put dummy double-quotes around variables containing spaces. But the eval will at least expand variables already known to the shell.

You don't need the `echo export` business.