Cover V10, I03

mar2001.tar


Listing 2 read_config

####################################################
# KSH Function: read_config                       
# Author      : Rainer Raab (raabrr@yahoo.com)   
# Date        : 11/28/2000                       
####################################################
# Description : Reads a configuration file and
# exports variables to the shell. The configuration
# file must be in text. If the first character in a
# line contains a "[", "#" or the line is empty, the
# entire line is ignored. If a configuration file
# contains the special EMAIL_LIST variable, then
# that variable must be a space separated list of
# e-mail recipients. 
####################################################
# Usage:
# CONFIG_FILE=/path_to_file/config_file
#
# Configuration File Format:
#
# [Section]
#  VARIABLE=value
#
# Configuration File Example:
# [Delays]
# # Delays are specified in seconds
# DELAY_1=60
# DELAY_2=300
#
# [Log files]
# OUT_LOG=/var/adm/test_out.log
# ERR_LOG=/var/adm/test_err.log
####################################################

function read_config {
while read LINE; do
COLUMN1=$(printf "$LINE\n"|cut -c1,1)
if [[ $COLUMN1 != "[" && $COLUMN1 != "#" && $COLUMN1 != "" ]]; then
LABEL=$(printf "$LINE\n"|awk -F= '{ print $1 }')
if [[ $LABEL = "EMAIL_LIST" ]]; then
EMAIL_LIST=$(printf "$LINE\n"|awk -F= '{ print $2 }')
else
export $LINE
fi
fi
done < $CONFIG_FILE
}