The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
retrive lines from a file using AWK command swamymns Shell Programming and Scripting 1 05-04-2008 10:47 PM
Parse Text file and send mails Amruta Pitkar UNIX for Dummies Questions & Answers 12 08-11-2006 04:56 AM
replacing a string in a file with command line parameter chiru_h Shell Programming and Scripting 5 08-03-2006 10:34 AM
export command radhika03 UNIX for Dummies Questions & Answers 2 12-16-2005 09:25 AM
using export command sveera Shell Programming and Scripting 4 04-01-2005 12:05 PM

 
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 11-06-2008
rajan_san rajan_san is offline
Registered User
  
 

Join Date: Aug 2008
Posts: 39
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
awk/sed script to read values from parameter files

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.

Last edited by rajan_san; 11-06-2008 at 08:49 AM.. Reason: Forgot Content
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 08:49 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0