<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EstiloDeEmail17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>As simple as possible is usually the best way. <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>$ru=avp(i:1); <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Is ok. <o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Flavio E. Goncalves<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span lang=PT-BR style='font-size:10.0pt;font-family:
"Tahoma","sans-serif"'>De:</span></b><span lang=PT-BR style='font-size:10.0pt;
font-family:"Tahoma","sans-serif"'> users-bounces@lists.opensips.org
[mailto:users-bounces@lists.opensips.org] <b>Em nome de </b>Phillip Jones<br>
<b>Enviada em:</b> Wednesday, February 24, 2010 5:49 PM<br>
<b>Para:</b> OpenSIPS users mailling list<br>
<b>Assunto:</b> Re: [OpenSIPS-Users] exec_dset / mySQL / SER<o:p></o:p></span></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'>Thank you both for that help.<br>
<br>
I have gone ahead and successfully implemented the avp_db_query version and I
now have a variable $avp(i:1) that contains the correct forwarding uri.<br>
<br>
Now this is really where I show my ignorance.<br>
<br>
How go I use $avp(i:1) correctly, considering that I am going to call t_relay()<br>
<br>
if (!t_relay()) <br>
{ <br>
sl_reply_error();<br>
};<br>
<br>
Is it simply a case of $ru = $avp(i:1);<br>
<br>
That appears to work but I just want to make sure it is the correct approach.<br>
<br>
Thanks again<br>
<br>
pj<br>
<br>
<br>
<o:p></o:p></p>
<div>
<p class=MsoNormal>On Wed, Feb 24, 2010 at 2:25 PM, Brett Nemeroff <<a
href="mailto:brett@nemeroff.com" target="_blank">brett@nemeroff.com</a>>
wrote:<o:p></o:p></p>
<p class=MsoNormal>Something else I wanted to mention regarding your code
here.. There is an obvious race condition if two calls come in at once.. your
script writes the query results to a tmp file which could already be written by
another call.<o:p></o:p></p>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>Overall, exec_dset should be avoided IMO. avp_db_query is
fast, and easy to implement. I think you'll be happy with the results. The
conversion should be simple enough, especially if your shell script really is
that simple..<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal>-Brett<o:p></o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<div>
<p class=MsoNormal><o:p> </o:p></p>
<div>
<div>
<p class=MsoNormal>On Wed, Feb 24, 2010 at 12:44 PM, Phillip Jones <<a
href="mailto:pjintheusa@gmail.com" target="_blank">pjintheusa@gmail.com</a>>
wrote:<o:p></o:p></p>
</div>
<blockquote style='border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;
margin-left:4.8pt;margin-right:0in'>
<div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'>Hi there,<br>
<br>
I am new to opensips - and I am trying to convert a script currently working in
SER. I am almost done - but have one last issue that is getting the better of
me. This is the script part:<br>
<br>
exec_dset('<br>
<br>
AQUERY="CALL Routing(\"$$SIP_USER\", \"$$SIP_SRCIP\",
\"$$SIP_RURI\", \"$$SIP_ORURI\", False);";<br>
AURI=`mysql -Broot -pxxxxxxx -e "$$AQUERY" opensips`;<br>
<br>
echo $$AQUERY > /tmp/AQUERY.txt<br>
echo $$AURI> /tmp/AURI.txt<br>
<br>
if
[ ! -z "$$AURI" ] ; then<br>
<br>
printf ("$$AURI");
<br>
fi;<br>
<br>
exit;<br>
<br>
echo > dev/null<br>
<br>
');<br>
<br>
AURI contains "+-----------------------------------+ | DestinationURI |
+-----------------------------------+ | sip:121255555666@64.55.55.555:5060 |
+-----------------------------------+" which kind of makes sense.<br>
<br>
Opensips falls over with error: ERROR:core:parse_uri: bad uri - which also
makes sense.<br>
<br>
If I use printf ("sip:121255555666@64.55.55.555:5060"); then every
thing works nicely.<br>
<br>
What I am missing here? If this worked in SER - what has changed - a config in
MySQL??<br>
<br>
Any help would be much appreciated. I think I could use REGEX here to extract
the uri, but I not familiar with the syntax in opensips.<br>
<br>
<br>
<br>
Thanks<br>
<span style='color:#888888'><br>
<br>
pj</span><o:p></o:p></p>
</div>
</div>
<div>
<p class=MsoNormal style='margin-bottom:12.0pt'>_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p>
</div>
</blockquote>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.opensips.org" target="_blank">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p>
</div>
<p class=MsoNormal><o:p> </o:p></p>
</div>
</body>
</html>