#!/usr/bin/ksh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/lib/nim/methods/c_showdump.sh 1.4 
#  
# Licensed Materials - Property of IBM 
#  
# Restricted Materials of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2008,2009 
# 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 
# @(#)20    1.4  src/bos/usr/lib/nim/methods/c_showdump.sh, cmdnim, bos720  3/15/09  15:42:36
#
# include common NIM shell defines/functions
NIMPATH=${0%/*}
NIMPATH=${NIMPATH%/*}
[[ ${NIMPATH} = ${0} ]] && NIMPATH=/usr/lpp/bos.sysmgt/nim
NIM_METHODS="${NIMPATH}/methods"
. ${NIM_METHODS}/c_sh_lib
#${ECHO} $0 $@

#---------------------------- local defines     --------------------------------

#---------------------------- module globals    --------------------------------
REQUIRED_ATTRS="location client server dump"
OPTIONAL_ATTRS="verbose"


#*---------------------------- c_showres           ----------------------------
#
# NAME: c_showres
#
# FUNCTION:
#    sets up remote access to resources, then runs a command to show
#    information about the resource
#
# EXECUTION ENVIRONMENT:
#
# NOTES:
#
# RECOVERY OPERATION:
#
# DATA STRUCTURES:
#    parameters:
#    global:
#
# RETURNS: (int)
#    0              = no errors
#    >0              = failure
#
# OUTPUT:
#-----------------------------------------------------------------------------*/

# signal processing
trap cleanup 0
trap err_signal 1 2 11 15

# NIM initialization
nim_init

# initialize local variables
typeset c=""
typeset client=""

# set parameters from command line
while getopts :a:qv c
do
  case ${c} in

    a)    # validate the attr ass
        parse_attr_ass "${OPTARG}"

        # include the assignment for use in this environment
        eval ${variable}=\"${value}\"
    ;;

    q)    # show attr info
        cmd_what
        exit 0
    ;;

    v)    # verbose mode (for debugging)
        set -x
        for i in $(typeset +f)
        do
          typeset -ft $i
        done
    ;;

    \?)   # unknown option
        error ${ERR_BAD_OPT} ${OPTARG}
    ;;

  esac
done


cd $location/$client

${ECHO} ""

if [[ -n ${client} ]]
then
	${ECHO} "$client:"
else
	${ECHO} "$dump:"
fi
${ECHO} "   dump      = $dump"
${ECHO} "   server    = $server"
${ECHO} "   location  = $location/$client"


find . -name "dump.*" -o -name "snap.Z.*" | while read DUMP
do

	[[ ( ${DUMP} == *"dump."* ) ]] && DFILE="dump"
	[[ ( ${DUMP} == *"snap.Z."* ) ]] && DFILE="snap"

	if [[ -z ${client} ]]
	then
		${ECHO} "`dirname ${DUMP}`:"
	fi
	
	${ECHO} "   ${DFILE}_file = $DUMP"
	DTIME=`ls -nl $DUMP | awk '{ print $6 " " $7 " " $8}' `
	${ECHO} "   ${DFILE}_time = $DTIME"
done
${ECHO} ""

# success
exit 0
