: /bin/sh ################################################################# # batch file for finding calls # CUSTOMDESC # CUSTOMDEF progname=$0 EXCL_PAR_LIST='"UNA", "TLM"' EXCL_SITEID_LIST='201' SDATE=$1; EDATE=$2; STIME=$3; ETIME=$4 if [ -n "$5" ]; then SITEID=$5 fi echo "SDATE=$SDATE" echo "EDATE=$SDATE" echo "STIME=$STIME" echo "ETIME=$ETIME" echo "SITEID=$SITEID" if [ -n "$6" ]; then P6=$6 else P6="" fi if [ -z "$OPASSISTDIALNUMS" ]; then echo "swb9 ERROR: OPASSISTDIALNUMS env var not set" exit 1 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 }' } ################################################################# # MAIN TMPSTABLE="swb9$LOGNAME" tmpfile=/tmp/swb_$$ tmpfile0=/tmp/swb0_$$ tmpfile1=/tmp/swb1_$$ tmpfile2=/tmp/swb2_$$ rm -f $tmpfile rm -f $tmpfile0 rm -f $tmpfile1 rm -f $tmpfile2 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 ######## #Testing #SDATE="01/02/2004" #EDATE="29/02/2004" ######## #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 [ "$SITEID" = "ALL" ]; then SITEBIT="" else SITEBIT="and siteid = $SITEID" fi # send file to user #exec 1>$tmpfile 2>&1 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'` dd=$sdd; mm=$smm; yyyy=$syyyy while true do dodate="$dd/$mm/$yyyy" tbldate=`echo $dodate | sed -e 's/\//_/g'` cdrtable="c$tbldate" #echo "dodate=$dodate cdrtable=$cdrtable dd=$dd mm=$mm yyyy=$yyyy" #echo #echo " For $dodate" runisql 2>&1 <>$tmpfile2 rm -f $tmpfile1 # increment date variables dd=`expr $dd + 1 | awk '{printf("%02d\n",$1)}'` if [ $dd -gt `lastdayinmonth $mm $yyyy` ]; then dd=01 mm=`expr $mm + 1 | awk '{printf("%02d\n",$1)}'` if [ $mm -gt 12 ]; then mm=01 yyyy=`expr $yyyy + 1 | awk '{printf("%04d\n",$1)}'` fi fi # break out if we are past end date if [ $yyyy$mm$dd -gt $eyyyy$emm$edd ]; then break; fi #echo done #echo #echo " End\f" # add in extension from directory to get 0 totals for extns without calls runisql 2>&1 <>$tmpfile2 # sort calls so they are in par,eggrid,extn,date,time order sort $tmpfile2 >$tmpfile0 # output to user #cat $tmpfile | pr_rep system swb_ cp $tmpfile0 s9.in rm -f $tmpfile rm -f $tmpfile0 rm -f $tmpfile1 rm -f $tmpfile2 exit 0