#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/db2/KLIB_DB2_get_env_array.sh 1.4 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2005,2011 # All Rights Reserved # # US Government Users Restricted Rights - Use, duplication or # disclosure restricted by GSA ADP Schedule Contract with IBM Corp. # # IBM_PROLOG_END_TAG # @(#)88 1.4 src/43haes/lib/ksh93/db2/KLIB_DB2_get_env_array.sh, hacmp, 61haes_r714 11/28/11 15:22:29 # #=head1 NAME # # KLIB_DB2_get_env_array - read the DB2 instance environment variables # into a hash # #=head1 SYNOPSIS # # . /usr/es/sbin/cluster/sa/db2/etc/db2.disc # unset INST_ENVIRONMENT # typeset -A INST_ENVIRONMENT # KLIB_DB2_get_env_array "db2inst1" INST_ENVIRONMENT || { # echo "ERROR: Unable to obtain instance environment data." # } # #=head1 DESCRIPTION # # This function reads the DB2 instance environment variables # from the discovery file and returns the results in a # hash array. # #=head1 ARGUMENTS # # 1: [scalar] DB2 instance name # 2: [by ref] hash of environment variables # #=head1 RETURN # # 0: success, DB2 instance environment was stored in the array # 1: failed # #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_DB2_get_env_array { . /usr/es/lib/ksh93/func_include instance=$1 typeset -n array=$2 typeset -n this="DB2_INSTANCE_$instance" for envvar in ${!this[*]}; do if [[ ${envvar:0:3} == "ENV" ]]; then value=${this[$envvar]} name=${envvar/ENVGLOBAL_/} name=${name/ENVINST_/} array[$name]=$value fi done return 0 }