Following is the js i am using to select route and bridge the call....<br><br><br>use(&quot;ODBC&quot;);<br><br>var DSN         = &quot;myodbc&quot;;<br>var DB_USER = &quot;neo&quot;;<br>var DB_PASS = &quot;.....&quot;;<br>
<br>var sql;<br><br>var prefix1;<br>var ip1;<br>var no2;<br><br>var bridge_str;<br><br>if(argv[0]==&quot;&quot;)<br>exit();<br><br><br>if(argv[1]==&quot;&quot;)<br>exit();<br><br><br>ip1 =argv[0].split(&quot;@&quot;)[1];<br>
<br><br>var no1=argv[1];<br><br>var sql = &quot;SELECT id,prefix,name FROM internal_auth where substring(&#39;&quot;+no1+&quot;&#39;,1,length(prefix))=prefix and ip=&#39;&quot; + ip1 +&quot;&#39; and active=1;&quot;;<br><br>
var authName=&quot;&quot;;<br><br>var db = new ODBC(DSN, DB_USER, DB_PASS);<br><br>db.connect();<br><br>db.query(sql);<br><br>if(db.nextRow()) {<br><br>     var row = db.getData();<br>     <br>    if (row[&quot;id&quot;] == &quot;&quot; ) {<br>
        console_log(&quot;Err&quot;, &quot;auth failed(0001)\t&quot; + no1 + &quot;\targ[0]=&gt;&quot; + argv[0] + &quot;\targ[1]=&gt;&quot; + argv[1] + &quot;\n&quot;); <br>        db.close();<br>         exit();<br>    }<br>
    <br>    prefix1=row[&quot;prefix&quot;]; authName=row[&quot;name&quot;];<br>    <br>}else{<br>        console_log(&quot;Err&quot;, &quot;auth failed(0001)\t&quot; + no1 + &quot;\targ[0]=&gt;&quot; + argv[0] + &quot;\targ[1]=&gt;&quot; + argv[1] + &quot;\n&quot;); <br>
        db.close();<br>         exit();<br>    <br>}<br><br><br>no2=no1.substring(prefix1.length, no1.length);<br><br>sql = &quot;SELECT  ec.* FROM auth_routes_carriers arc,external_carriers ec, codes c where arc.external_carriers_id = <a href="http://ec.id">ec.id</a> and arc.code_id = <a href="http://c.id">c.id</a> and substring(&#39;&quot;+no2+&quot;&#39;,1,length(c.code))=c.code and ec.active=1 order by arc.priority asc&quot;;<br>
<br>db.connect();<br><br>db.query(sql);<br><br>var carriersName=&quot;&quot;;<br><br>bridge_str=&#39;&#39;;<br><br>while(db.nextRow()) {<br><br>    var row = db.getData();<br>         <br>    if (row[&quot;id&quot;] != &quot;&quot; ) {<br>
        bridge_str = row[&quot;gateway&quot;]+row[&quot;prefix&quot;]+no2+&quot;\@&quot;+row[&quot;ip&quot;]; <br>          carriersName = row[&quot;name&quot;];<br>           break; <br>    }<br><br>}<br><br>db.close();<br>
<br>if(bridge_str != &#39;&#39;){<br>    if(session.ready()) session.execute(&quot;bridge&quot;, bridge_str);    <br>}<br>else {<br>    console_log(&quot;Err&quot;, &quot;external carrier not found.\t&quot; + no2 + &quot;\targ[0]=&gt;&quot; + argv[0] + &quot;\targ[1]=&gt;&quot; + argv[1] + &quot;\n&quot;); <br>
    exit();<br>}<br><br><br>exit();<br><br><br><br>