: !/bin/sh ######################################################################## # T21BATCHNAME calldet3.t21batch # T21BATCHDESC Extension Call Detail Reports # ALLOWBLANKDATES false # CUSTOMDESC Email Address # CUSTOMDEF `cat /u/catcom/database/reports.emaillist` # T21BATCHVAR1DESC Enter Extension GroupID # T21BATCHVAR1VALU ALL # T21BATCHVAR2DESC Enter Extension (space delimited list) # T21BATCHVAR2VALU 1 # T21BATCHVAR3DESC # T21BATCHVAR3VALU # T21BATCHVAR4DESC # T21BATCHVAR4VALU # T21BATCHVAR5DESC # T21BATCHVAR5VALU # T21BATCHENDARGS ######################################################################## # command line args SDATE=$1; EDATE=$2; STIME=$3; ETIME=$4 if [ -n "$5" ]; then SITEID="$5" else #SITEID="ALL" SITEID="" fi if [ -n "$6" ]; then CUSTPARAM="$6" else CUSTPARAM="$LOGNAME" fi if [ -n "$T21BATCHVAR1VALU" ]; then EGRID="$T21BATCHVAR1VALU" else EGRID="" fi if [ -n "$T21BATCHVAR2VALU" ]; then EXTNLIST="$T21BATCHVAR2VALU" else EXTNLIST="" 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 ################################################################# ## Testing #SDATE="20/08/2015" #EDATE="26/08/2015" #STIME="00:00" #SITEID="ALL" #ETIME="24:00" #EGRID="ALL" #EXTNLIST="87300 87301 87302 87303 87304 87305 87306 87307 87308 87309 87310 87311 83700 83701 83702 83703" #EMAIL_ADDRESS="support@transmit.com.au" ################################################################# 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 "$EMAIL_ADDRESS" ]; then if [ -z "$CUSTPARAM" ]; then echo "Enter Email Address:\c"; read CUSTPARAM fi if [ -n "$CUSTPARAM" ]; then EMAIL_ADDRESS="$CUSTPARAM" else EMAIL_ADDRESS="$LOGNAME" fi 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/extncalldet3_$$" ########################################################################### ########################################################################### ########################################################################### ########################################################################### # send script output output to file exec >$tmpfile 2>&1 DODBG="false" export DODBG #echo "HOME=[$HOME]" ########################################################################### echo "." echo "." echo "Log Information..." echo "." echo "Starting $0: $SDATE $EDATE $STIME $ETIME $SITEID $EGRID $EXTNLIST" 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 # text with "csv" file extension # emailed as file attchments ALL-In-ONE email RPTOPTSTEMP="tmp/.t21rptopts.tmp$runont21_pid" echo "RPTOPTSTEMP=[$RPTOPTSTEMP]" R="$0"; export R ################################################################# ############################################################### # Generat Reports for EXTN in $EXTNLIST do #callextdet $SDATE $EDATE $STIME $ETIME E $SITEID "$EGRID" 384 385 echo "run: callextdet $SDATE $EDATE $STIME $ETIME E $SITEID \"$EGRID\" $EXTN" cat > $HOME/$RPTOPTSTEMP <