<div dir="ltr">Hi<div><br></div><div>I am trying to make a kamailio script which gets a uri from the database and then directs the call to that uri. Setting the uri with a string (not derived from the database) works just fine:</div>
<div><br></div><div><div>append_branch();<br></div><div>seturi("sip:user@domain");<br></div></div><div><br></div><div>But I can not seem to pass anything to seturi other than a string. Here are some examples:</div>
<div><br></div><div><div>$var(branch_uri) = $dbr(ra=>[0,0]);</div><div>append_branch();</div></div><div>seturi($var(branch_uri));<br></div><div><br></div><div># kamailio won't even start when I try to pass the uri from a variable</div>
<div><br></div><div><div><div>$var(branch_uri) = $dbr(ra=>[0,0]);</div><div>append_branch();</div></div><div>seturi("$var(branch_uri)");</div></div><div><br></div><div># treats the "$var(branch_uri)" as a literal string -- does not evaluate to the the value of the variable</div>
<div><br></div><div><div><div>$var(branch_uri) = $dbr(ra=>[0,0]);</div><div>append_branch();</div></div><div>seturi((str)$var(branch_uri));</div></div><div><br></div><div># kamailio won't start with this syntax inplace</div>
<div><br></div><div>The errors that kamailio gives on start up when I have a variable in passed into seturi are as follows</div><div><br></div><div><div> 0(16145) : <core> [cfg.y:3567]: yyerror_at(): parse error in config file /usr/local/kamailio-4.0/etc/kamailio/kamailio.cfg, line 647, column 12-27: syntax error</div>
<div> 0(16145) : <core> [cfg.y:3570]: yyerror_at(): parse error in config file /usr/local/kamailio-4.0/etc/kamailio/kamailio.cfg, line 647, column 28: bad argument, string expected</div><div> 0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record(): find_export_record: found <sl_reply_error> in module sl [/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]</div>
<div> 0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record(): find_export_record: found <sl_reply_error> in module sl [/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]</div><div> 0(16145) DEBUG: <core> [sr_module.c:674]: find_mod_export_record(): find_export_record: found <sl_reply_error> in module sl [/usr/local/kamailio-4.0/lib64/kamailio/modules/sl.so]</div>
<div>ERROR: bad config file (2 errors)</div></div><div><br></div><div><div>I also tried to accomplish this </div></div><div><br></div><div><div><div>append_branch($var(branch_uri), "0.0");</div><div>t_load_contacts();</div>
<div>t_next_contacts();</div></div><div><br></div><div># No errors but didn't work</div></div><div><br></div><div>I found a way around the problem by making a perl script to allow me set the uri:</div><div><br></div><div>
Perl script:</div><div><br></div><div><div>sub rewrite_uri {</div><div>        my $m = shift;</div><div>        my $uri = shift;</div><div>        $m->rewrite_ruri($uri);</div><div>        return -1;</div><div>}</div></div>
<div><br></div><div>Then I call it like this:</div><div><br></div><div><div>$var(branch_uri) = $dbr(ra=>[0,0]);</div><div>append_branch();</div><div>perl_exec("rewrite_uri", $var(branch_uri));</div></div><div>
<br></div><div># this works</div><div><br></div><div><br></div><div>So I have a viable work around but it seems like there is probably something simple I am missing which should let me accomplish this with out having to do a call into perl.</div>
<div><br></div><div>Any advice any one can give me would be greatly appreciated.</div><div><br></div><div>Best regards</div><div><br></div><div>Will Ferrer</div><div><br></div></div>