#!/usr/bin/sh
# IBM_PROLOG_BEGIN_TAG 
# This is an automatically generated prolog. 
#  
# bos720 src/bos/usr/bin/cdat/smit/cdat_disc_sched_coll.sh 1.2 
#  
# Licensed Materials - Property of IBM 
#  
# COPYRIGHT International Business Machines Corp. 2010,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 
# @(#)34    1.2  src/bos/usr/bin/cdat/smit/cdat_disc_sched_coll.sh, cdat, bos720 7/15/11 03:44:39
# This command returns the values of the specified scheduled collect
# recorded in the cdat user cron file
#

PATH=/bin:/sbin:/usr/bin:/usr/sbin

[ $# -ne 1 ] && \
	echo "Usage: $0 <collect name>" && exit 1

MUSER=`/usr/lib/cdat/smit/cdat_init_values | sed -n 2p \
	| sed -ne 's/:.*$//p'`
# crontab: call crontab to get scheduled collect
# grep: suppress comment line
# sed: change <tab> in space
# grep: select line including /usr/bin/cdat collect and collect name
# sed: add \ before * to avoid * interpretation in system()
# awk: print collect name and type
crontab -l $MUSER | grep -v "^#" | sed -e 's/	/ /' | \
	grep "/usr/bin/cdat  *collect " | grep "[ '\"]-i[ '\"]*${1}[ '\"]" | \
	sed -e 's:\*:\\\*:g' | \
	awk '{
		system( "/usr/lib/cdat/smit/cdat_pr_disc_sched_coll " $0)
		exit 0
	}'
exit 0