Hylafax Mailing List Archives

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [hylafax-users] Hylafax DB integration (postgresql) and/or API



Hi!

I done hylaFAX incoming faxes archive with mySQL thru shell scripts,
and minor modifications of faxrcvd script with simple script (see below).
I think possible to solve it on this level.

Regards,
Alexander Slepoy aka AlexZ75
http://hylafront.imacrovision.com


#!/bin/bash
# insert fax into fax log
# $1 FAXNO
# $2 SENDNAME
# $3 IDFIRM
# $4 FileName
#
######################
# 1st convert faxno to dial format & get params
#
if [ $# -lt 6 ]; then
    echo "usage:"
    echo "$0 <fax-no> <send_name> <idfirm> <FileName> <error_msg>
<pagecount>"
    exit 1;
    fi
#REMOVE COUNTRY CODE & PREFIX
FAXNO=`echo $1 | sed -e 's/^972/0/g'`;
FAXNO=`echo $FAXNO | sed -e 's/^03//g'`;
SENDNAME=$2;
IDFIRM=$3;
DEFAULTGROUP=-1;
FILENAME=$4;
ERRMSG=$5;
PAGECOUNT=$6;
NOW=`date +'%Y-%m-%d %H:%M:%S'`;
MYSQL_PWD="****";
MYSQL_USR="****";
MYSQL_DB="FaxSorter";
MYSQL_HOST="fax.abc";

# IF HAVE FAXNO
if [ -n "$1" ]; then
####################
# get id if have in phonebook
GETQRY="SELECT idphone FROM phonebook WHERE phone_faxno='"$FAXNO"'";


#################################
# get phone info from sortrules 
# not have one here
GETSORTRULE="SELECT idrule, idfirm, idgroup, idphone, sort_folder FROM
sortrules WHERE sort_phone='$FAXNO'";
#echo $GETSORTRULE
result=$(mysql -h"$MYSQL_HOST" -u "$MYSQL_USR" -p"$MYSQL_PWD" -nB -D
"$MYSQL_DB" -e "$GETSORTRULE");
#idphone=`echo $result | awk '{print($2);}'`;
#echo $result
idrule=`echo $result | awk '{print($6);}'`;
idfirm=`echo $result | awk '{print($7);}'`;
idgroup=`echo $result | awk '{print($8);}'`;
idphone=`echo $result | awk '{print($9);}'`;
sortfolder=`echo $result | awk '{print($10);}'`;

# if not found rule, get from phone_book, but not sort it
if [ -z "$idrule" ]; then
# GET OWNER OF PHONE
    result=$(mysql -h"$MYSQL_HOST" -u "$MYSQL_USR" -p"$MYSQL_PWD" -nB -D
"$MYSQL_DB" -e "$GETQRY");
    idphone=`echo $result | awk '{print($2);}'`;
    idfirm=$IDFIRM;
    idgroup=$DEFAULTGROUP;

#    echo $idphone;

fi
# if not found phone, dont insertinfo
if [ -z "$idphone" ]; then
    idphone=-1
fi
################# FI FOR PHONE_NUM
else
sortfolder="";
idfirm=$IDFIRM;
idgroup=$DEFAULTGROUP;
idphone=-2;
fi 

# GET OWNER OF PHONE


############################
# insert into fax log
INSSQL="INSERT INTO inboxlog(idfirm, idgroup, idphone, fax_from, URL, TIME,
errmsg, pagecount) VALUES($idfirm, $idgroup, $idphone, '$FAXNO','$FILENAME',
'$NOW', '$ERRMSG',$PAGECOUNT )";
#echo $INSSQL
result=$(mysql -h"$MYSQL_HOST" -u "$MYSQL_USR" -p"$MYSQL_PWD" -nB -D
"$MYSQL_DB" -e "$INSSQL");



 


-----Original Message-----
From: hylafax-users-bounce@xxxxxxxxxxx
[mailto:hylafax-users-bounce@xxxxxxxxxxx] On Behalf Of doktora v
Sent: Thursday, August 12, 2004 9:26 AM
To: awilliam@xxxxxxxxxxxxx
Cc: hylafax-users@xxxxxxxxxxx
Subject: Re: [hylafax-users] Hylafax DB integration (postgresql) and/or API

Well maybe it's just me but I haven't found any scripts. Anyway I tend
to dislike scripts (just personal), and I want to give my
application/database access to hylafax information.

So, I sifted through the source code and found some useful things.
Borrowing the faxstat code and FaxClient, I was able to make a class
which transforms the faxstatus information into XML format.

Now that's much more portable and useful, wouldn't you say?

Well it's still frustrating that faxstat only seems to get data in raw
text format via (tcp?) connection to the server. The lenght of fields
is restricted and gets cut off.

But is there anything more direct (and perhaps more efficient) than
cat/grep'ing through the queues?

How can I have fax information be pushed to an external entity outside
of hylafax (like my own DB)? For example, when fax status change, have
the states automatically chaned in the DB? faxwatch seems to be
working along those lines but you'd have to register a separate
function for each of the 30 or so possible events (using recvData
function).!?

Maybe I'm not getting it right, but source code documentation is
minimal (if present at all).

Hylafax is a great tool but using files as a db seems a bit archaic
and the natural thing to do for me is try to hook it to an RDBMS. This
may mean digging deep in the source code... at least that's how I see
it now.

Any more specific help would be appreciated, or just your share of
experience. Enlighten...

cheers!

On Wed, 11 Aug 2004 22:15:04 -0400, Adam Tauno Williams
<awilliam@xxxxxxxxxxxxx> wrote:
> > Does Hylafax have a C/C++ API?
> > Does anyone know of any ongoing projects for hylafax with a database
> > integration?
> > (For example having outgoing/incomming faxes logged in a database.)
> 
> Everything is procesed via scripts;  hacking in your own functionality
> for archiving, recording, etc... doesn't require attacking the binaries.
> 
>

____________________ HylaFAX(tm) Users Mailing List _______________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
 On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
  *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*


____________________ HylaFAX(tm) Users Mailing List _______________________
  To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
 On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
  *To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*



Home
Report any problems to webmaster@hylafax.org

HylaFAX is a trademark of Silicon Graphics Corporation.
Internet connectivity for hylafax.org is provided by:
VirtuALL Private Host Services