Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> RE: Off topic: Unix Script Help Needed

RE: Off topic: Unix Script Help Needed

From: William Rogge <William_Rogge_at_voltek.com>
Date: Tue, 16 Jan 2001 10:02:25 -0500
Message-Id: <10743.126783@fatcity.com>


In order to do what you are looking to accomplish, you are best using UNIX functions.

The code you need would be something like this: (I am assuming that all files have a final line with just 'EOF'. - - - - - - -
# Function to walk through a passed filename evaluating both sides of an '=' sign
# Use parsed values when calling my_shell.sh script
Walk_Config ()
{
# Process the file

exec 6<$1
exec 7<&0
exec 0<&6 

read conf_line
while [ ! "$conf_line" = "EOF!" ]
do

    the_var=`echo $conf_line | awk -F= '{print $1}'`     the_val=`echo $conf_line | awk -F= '{print $2}'`     my_shell.sh $the_var $the_val
done
exec 0<&7
exec 6<&-
}

# Function to walk through Master.Conf file setting the value of the_conf from the file.
# Use the read file when calling function Walk_Config
Walk_Master ()
{
# Process the file

exec 4<master.conf
exec 5<&0
exec 0<&4 

read the_line
while [ ! "$the_line" = "EOF!" ]
do

    Walk_Config $the_line
done
exec 0<&5
exec 4<&-
}

# Main routine of shell script

Walk_Master
- - - - - - - - - - - - -

-----Original Message-----

From:	Valiveru, Siva [SMTP:SValiveru_at_ea.com]
Sent:	Monday, January 15, 2001 10:00 PM
To:	Multiple recipients of list ORACLE-L
Subject:	Off topic: Unix Script Help Needed

All,
I need help in writing a Unix shell script , here is our requirement, my script looks for master config file say, master.conf having values of the pattern 'filename' and reads all the entries till end of file, for each entry in the master.conf there will be o/s file in the same directory and my script looks for the all the configuration values having the simple pattern name=value in that file, based on the name and value I am doing some processing. Can somebody there provide me a direction to how to achieve this,

logic flow is as follows,

myscript.sh

  1. Read master.conf file
  2. look for each detail config file for each entry in master.file, error out if detail config file is missing and loops for end of file.
  3. Read each line of the individual file till end of file and take 'name' into $NAME variable and 'value' to $VALUE variable, call another script with these values as input to that script.

contents of master.conf

file1.conf
file2.conf

contents of file1.conf

variable1=10
variable2=20

content of file2.conf

variable3=30
variable4=40

-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Valiveru, Siva
  INET: SValiveru_at_ea.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
Received on Tue Jan 16 2001 - 09:02:25 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US