#!/bin/ksh # IBM_PROLOG_BEGIN_TAG # This is an automatically generated prolog. # # 61haes_r714 src/43haes/usr/sbin/cluster/utilities/cl_lsitab.sh 1.1 # # Licensed Materials - Property of IBM # # COPYRIGHT International Business Machines Corp. 2007 # 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 # @(#)48 1.1 src/43haes/usr/sbin/cluster/utilities/cl_lsitab.sh, hacmp.utils, 61haes_r714 12/4/07 09:44:46 ############################################################################ # # # Name: l_lsitab # # This routine lists displays the ith record from inittab file # # or can optionally display all the record on stdout. # # # # Argumets: [identifier]: list record matching identfier # # # # Flags : -a: list all records # # # # Returns: 0 - successfully displayed the record # # 1 - otherwise # # # ############################################################################ l_lsitab() { [[ "$VERBOSE_LOGGING" = "high" ]] && set -x set -u #parse arguments disp_all=FALSE while getopts a opt do case $1 in -a) disp_all=TRUE ;; esac done if [[ $disp_all = FALSE ]]; then id=$* [[ -z $id ]] && usage lsitab id=$1 rec_num=`awk -F':' -v id=$id '!/^\ *#/ && $1==id {print NR}' $INITTAB_FILE` [[ -z $rec_num ]] && return $E_ERROR #specified record not found #record found...display only that record echo "$(awk -v rec_num=$rec_num '!/^\ *#/ && NR == rec_num {print $0}' $INITTAB_FILE)" return $E_SUCCESS else #Display all lines NOT begining with '#' awk '!/^\ *#/ {print $0}' $INITTAB_FILE return $E_SUCCESS fi } #main [[ "$VERBOSE_LOGGING" = "high" ]] && set -x [[ "$VERBOSE_LOGGING" = "high" ]] && version='1.1' set -u PROGNAME=$(basename ${0}) export PATH="$($(dirname ${0})/cl_get_path all)" OSNAME=$(uname) if [[ ${OSNAME} = *AIX* ]]; then /usr/sbin/lsitab "$*" else source $(dirname ${0})/inittab_util l_lsitab "$*" fi