Received fax report for Hylafax using GAWK.

January 21, 2009 at 3:17 pm (coding, linux, TechTips) (, , , )

I like using the open source fax server software Hylafax for deploying fax services to a network.

One of the great things about using Hylafax for fax services, is the great flexibility you get.  Lately, one of my users requested that I create a report that could be automatically sent to her group daily.  This report was to show all faxes that were sent to their inbound fax number during the previous day.  In particular they wanted to be able to look for any faxes that someone had tried to send to them that failed for some reason.

I decied to use GAWK in order to parse the transfer log and create the resulting report.  Then, I wrapped this gawk script in a little bash script to add a little functionality.  Finally, this bash script was added to cron.daily, so as to produce the report and email it on a daily basis.

Simply change YOURFAXNUMBERHERE to be what receiving fax number you want to report on.  Finally you’ll want to pipe the output to mail if you want it to get emailed automatically.  I’m sure there are numerous better ways to make the format better, etc.  However, this is my quick script and it works perfectly for my needs.  Let me know if you find it useful.

#!/bin/bash

#####################################
# faxrecreport.sh
#
# Written by: Jason Fenner
#
# V 1.0
#
# 01/21/2009
#
# This report will print out all
# recv’d faxes for a certain inbound
# fax number that was received
# in the last 24 hour period.
#
####################################

DATEPERIOD=`date –date=yesterday +%D`
FAXNUMBER=”YOURFAXNUMBERHERE”

echo “Fax Receive Report”
echo
echo “——————”
echo “Fax Number: $FAXNUMBER”
echo “24 Hour Period for: $DATEPERIOD”
echo “——————”
echo
echo

awk -F’\t’ ‘BEGIN{ “date –date=yesterday +%D ” | \
getline dateVal; printf(“%15s%30s%15s%7s %8s%50s %12s\n”,”Date”,”Name”,”CallerID”,”Pages”,”Duration”,”Error”,”Ref”); \
for (x=1; x<=140; ++x) {printf( “%s” , “-” ) } \
print “” }
($2 ~ /RECV/ && $16 ~ /YOURFAXNUMBERHERE/ && $1 ~ dateVal) \
{gsub(/\”/,””); if ($14 == “”) $14 = “None”; \
if ($15 == “”) $15 = “Not Received”; \
printf(“%15s%30s%15s%7s %8s%50s %12s\n”, $1,$9,$15,$11,$13,$14,$3)
}

END{ for (x=1; x<=140; ++x) {printf( “%s” , “-” ) } \
print “” }’ /var/spool/hylafax/etc/xferfaxlog

Advertisements

3 Comments

  1. Simone MASI said,

    Hello,

    i’ve one question for you, have a script for daily report of the sended fax’s?

    Thank,

    Simone

    • axelilly said,

      What are you looking for then what the script that I posted is not doing?

      • Simone MASI said,

        I need to have a daily report of faxes sent

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: