[Serusers] ser and database

Sebastian Kühner skuehner at veraza.com
Mon Aug 1 21:23:22 CEST 2005


Hi!

Has anyone of you used a database to make routing?

For example:     If the caller marks 001  -> Rewritehost("xxx.xxx.xxx.111");
                        If the caller marks 0049 ->
Rewritehost("xxx.xxx.xxx.222");

The two host names are in my postgres database...

Once I used a command like this to stop calls of users that don't have
credit:

       if (!exec_msg('

              POS1=`expr index "$SIP_HF_FROM" sip: + 4`;

              LENGTH=`expr index "$SIP_HF_FROM" @ - $POS1`;

              USER=`expr substr "$SIP_HF_FROM" $POS1 $LENGTH`;



              QUERY="select credit from subscriber where username=$USER AND
credit > 0";

              RESULT=`psql -U postgres AAA -t -c "$QUERY"`;



              if [ -z "$RESULT" ] ; then exit 1; fi ;'

              ))

       {

                     sl_send_reply("403", "Sorry, not enough credit to make
this call.");

                     break;

       };





... but I have problems to get the result of a psql query... is there any
way to do it??



Thanks!!



Sebastian





More information about the sr-users mailing list