#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r720 src/43haes/lib/ksh93/db2/KLIB_DB2_get_dasadm_group.sh 1.8 # # Licensed Materials - Property of IBM # # Restricted Materials of IBM # # COPYRIGHT International Business Machines Corp. 2005,2015 # 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 # @(#)95 1.8 src/43haes/lib/ksh93/db2/KLIB_DB2_get_dasadm_group.sh, hacmp, 61haes_r720, 1539B_hacmp720 9/11/15 13:57:27 # #=head1 NAME # # KLIB_DB2_get_dasadm_group - Get the DAS DB2 administrator group for the specified instance # #=head1 SYNOPSIS # # group=$(KLIB_DB2_get_dasadm_group "db2inst1") # #=head1 DESCRIPTION # # Get the DAS DB2 administrator group for the specified instance # #=head1 ARGUMENTS # # 1: [scalar] DB2 instance user owner # which may be different from the instance name # #=head1 RETURN # # 0: success, found the group # 1: failed, unable to determine the group # #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_DB2_get_dasadm_group { . /usr/es/lib/ksh93/func_include user=$1 if [[ -z $user ]]; then return 1 fi LC_ALL=C /usr/bin/su - $user -c "db2 get admin cfg" | while IFS='=' read name value; do name=${name/ /} value=${value/ /} [[ "$name" && "$value" ]] && { short_name=${name/*\(/} short_name=${short_name/\)/} short_name=${short_name/ /} if [[ "$short_name" == "DASADM_GROUP" ]]; then echo $value return 0 fi } done return 1 }