#!/bin/ksh93 # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/lib/ksh93/db2/KLIB_DB2_get_bin_dir.sh 1.7 # # 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 # @(#)87 1.7 src/43haes/lib/ksh93/db2/KLIB_DB2_get_bin_dir.sh, hacmp, 61haes_r714 11/28/11 15:21:21 # #=head1 NAME # # KLIB_DB2_get_bin_dir - Obtain the DB2 binary (/usr/opt/db2_08_01/bin) directory for the local node # #=head1 SYNOPSIS # # bindir=$(KLIB_DB2_get_bin_dir) # [[ -n $bindir ]] && PATH=$PATH:$bindir:$bindir/../instance/ # db2iset -i db2inst1 # #=head1 DESCRIPTION # # Obtain the DB2 binary (/usr/opt/db2_08_01/bin) directory for the local node # #=head1 ARGUMENTS # # None # #=head1 RETURN # # echos to stdout the bin directory for the local install of DB2 #=head1 COPYRIGHT # #(C) COPYRIGHT International Business Machines Corp. 2005 #All Rights Reserved # #=cut # function KLIB_DB2_get_bin_dir { . /usr/es/lib/ksh93/func_include # # Obtain the path to the db2 client installation (DB2 bin directory) # /usr/bin/lslpp -Lc 'db2*' 2>/dev/null 1>&2 if [[ $? == 0 ]]; then /usr/bin/lslpp -Lc 'db2*' 2>/dev/null | while IFS=: read image tmp version tmp; do if [[ ${image/*db2.client/found} == "found" ]]; then DB2_CLIENT_IMAGE=$image fi if [[ ${image/*db2.engn/found} == "found" ]]; then DB2_ENGN_IMAGE=$image fi done DB2_CLIENT_PATH=$(/usr/bin/lslpp -f $DB2_CLIENT_IMAGE | grep db2ilist | grep -v "\->" | head -n 1) DB2_CLIENT_PATH=${DB2_CLIENT_PATH/\/db2ilist/} # Strip the db2ilist command from the tailing end echo $DB2_CLIENT_PATH | read -r DB2_CLIENT_PATH # Strip whitespace echo $DB2_CLIENT_PATH else DB2_CLIENT_PATH=${DSE_INSTALL_DIR}/bin echo $DB2_CLIENT_PATH fi }