of course you can do this. you need to read up more on the exec module, I have a script that decides which outgoing trunk to use
based on the from number, the prepends digits so the gateway knows which way to send it. i use something like this.
 
 if ( method == "INVITE" ) {
                  
if (!exec_dset("/usr/local/sbin/npanxx_lookup")) {
                                        sl_reply_error();
                                };
                        };
from the script you can use specific environment variables to get the FROM and TO numbers among other things.
 
like URI=$SIP_RURI and FROM=$SIP_HF_FROM
 
after you run through your logic simply "echo" or "print" your new URI and you're done.
 
Ray

From: serusers-bounces@lists.iptel.org [mailto:serusers-bounces@lists.iptel.org] On Behalf Of andrew matthews
Sent: Thursday, July 14, 2005 12:01 PM
To: serusers@lists.iptel.org
Subject: [Serusers] Complex routing

I'm looking for a way to look up a phone number and then prepending a prefix to the number then forwarding it to a host...


Basicly something like this

result=exec('/home/scripts/lookup.pl 800-555-1212')


               if(result)
                                # Lookup failed, assume that this is a phonenumber URL until I setup pattern matching
                                # Send to the TNT
                                xlog("L_INFO", "Sending URI (%ru) to TNT");
                                prefix(result);
                                rewritehostport("10.1.1.5:5060")
                        };



basicly then result would contain 333, or 555, or 777. Depending on then number that was returned from lookup.pl


is there anyway to do this? Or any other way to do it?

Thanks

Andrew