: !/bin/sh ######################################################################## # T21BATCHNAME extnusage2.t21batch # T21BATCHDESC Extension Usage Reports # ALLOWBLANKDATES false # CUSTOMDESC Email Address # CUSTOMDEF `cat /u/catcom/database/reports.emaillist` # T21BATCHVAR1DESC Enter Extension GroupID # T21BATCHVAR1VALU EG_HTG # T21BATCHVAR2DESC # T21BATCHVAR2VALU # T21BATCHVAR3DESC # T21BATCHVAR3VALU # T21BATCHVAR4DESC Include Weekends # T21BATCHVAR4VALU N # T21BATCHVAR5DESC Enter Extension (space delimited list) # T21BATCHVAR5VALU 1 # T21BATCHENDARGS ######################################################################## # command line args SDATE=$1; EDATE=$2; STIME=$3; ETIME=$4 if [ -n "$5" ]; then SITEID="$5" else #SITEID="ALL" SITEID="201" fi if [ -n "$6" ]; then CUSTPARAM="$6" else CUSTPARAM="$LOGNAME" fi if [ -n "$T21BATCHVAR1VALU" ]; then EGRID="$T21BATCHVAR1VALU" else EGRID="" fi if [ -n "$T21BATCHVAR4VALU" ]; then INCLUDEWEEKENDS="$T21BATCHVAR4VALU" else INCLUDEWEEKENDS="Y" fi if [ -n "$T21BATCHVAR5VALU" ]; then EXTNLIST="$T21BATCHVAR5VALU" else EXTNLIST="ALL" fi ################################################################# lastdayinmonth() # Returns the last day in month, Inputs: $1=mm $2=yyyy { cal $1 $2 | awk '{ if ( NF > 0 ) x=$NF } END { print x }' } monthname() # Returns the month name, Inputs: $1=mm { awk -v "mm=$1" 'BEGIN { monthnamearr[1] = "Jan" monthnamearr[2] = "Feb" monthnamearr[3] = "Mar" monthnamearr[4] = "Apr" monthnamearr[5] = "May" monthnamearr[6] = "Jun" monthnamearr[7] = "Jul" monthnamearr[8] = "Aug" monthnamearr[9] = "Sep" monthnamearr[10] = "Oct" monthnamearr[11] = "Nov" monthnamearr[12] = "Dec" print monthnamearr[mm + 0] exit 0 }' } ################################################################# # MAIN umask 0 ################################################################# if [ -z "$SITEID" ]; then echo "Enter siteid (Enter for ALL):\c"; read SITEID fi if [ -z "$SITEID" ]; then SITEID="ALL" fi if [ -z "$SDATE" ]; then echo "Enter start date:\c"; read SDATE fi if [ -z "$EDATE" ]; then echo "Enter end date:\c"; read EDATE fi if [ -z "$STIME" ]; then echo "Enter start time:\c"; read STIME fi if [ -z "$ETIME" ]; then echo "Enter end time:\c"; read ETIME fi #if [ -z "$EGRID" ]; then # echo "Enter ExtnGroupID (Enter for ALL):\c"; read EGRID #fi if [ -z "$EGRID" ]; then EGRID="ALL" fi #if [ -z "$EXTNLIST" ]; then # echo "Enter Extn (space delim list) (Enter for ALL):\c"; read EXTN #fi if [ -z "$EXTNLIST" ]; then EXTNLIST="1" fi if [ -z "$INCLUDEWEEKENDS" ]; then echo "Enter Include Weekends (y/n):\c"; read INCLUDEWEEKENDS fi if [ "$INCLUDEWEEKENDS" = "N" -o "$INCLUDEWEEKENDS" = "n" ]; then INCLUDEWEEKENDS="N" else INCLUDEWEEKENDS="Y" fi if [ -z "$CUSTPARAM" ]; then echo "Enter Email Address:\c"; read CUSTPARAM fi if [ -n "$CUSTPARAM" ]; then EMAIL_ADDRESS="$CUSTPARAM" else EMAIL_ADDRESS="$LOGNAME" fi ######################################################################### # setup for SQL if [ "$SITEID" = "ALL" ]; then SITEBIT="" else SITEBIT="and siteid = $SITEID" fi ######################################################################### # fix params for running report if [ "$SITEID" = "ALL" ]; then SITEID="Nulls" fi EGRID=`echo "$EGRID" | awk '{ print toupper($0) }'` if [ "$EGRID" = "ALL" ]; then EGRID="Nulls" fi ########################################################################### # temp files tmpfile="/tmp/extnusage2_$$" tmp1file="/tmp/extnusage2_1_$$" tmp2file="/tmp/extnusage2_2_$$" ########################################################################### ########################################################################### ########################################################################### ########################################################################### # send script output output to file exec >$tmpfile 2>&1 ########################################################################### echo "Log..." echo "" echo "Starting $0: $SDATE $EDATE $STIME $ETIME $SITEID $EGRID $EXTNLIST $INCUDEWEEKENDS" date sdd=`echo $SDATE | sed -e 's/\/..\/....$//g'` smm=`echo $SDATE | sed -e 's/^..\///g;s/\/....$//g'` syyyy=`echo $SDATE | sed -e 's/^..\/..\///g'` edd=`echo $EDATE | sed -e 's/\/..\/....$//g'` emm=`echo $EDATE | sed -e 's/^..\///g;s/\/....$//g'` eyyyy=`echo $EDATE | sed -e 's/^..\/..\///g'` # set month and year to be used in filename MMM_YYYY="`monthname ${smm}`_${syyyy}" ######################################################################### ######################################################################### ########################################################################### # prepare for report output setting to be controlled within this script # disable rpt options set if spooled if [ "$spoolt21rptopts" = "1" ]; then spoolt21rptopts=0 export spoolt21rptopts runont21_pid=$rptque_pid fi # make sure runont21_pid is set for srct21rptopts script to find temp rpt opts if [ -z "$runont21_pid" ]; then runont21_pid="$$" fi export runont21_pid # must be set so pr_rep sets uue_pid dobatch_pid=$runont21_pid; export dobatch_pid # set pr_rep env file name for concat/email ALL-IN-ONE if [ -z "$pr_rep_env_file" ]; then pr_rep_env_file="$HOME/pr_rep.env$runont21_pid" export pr_rep_env_file fi ####################################################################### ####################################################################### # setup report output options to be # rich text, word landscape # emailed as a single concatenated file atttchment RPTOPTSTEMP="tmp/.t21rptopts.tmp$runont21_pid" cat > $HOME/$RPTOPTSTEMP <