Álvaro Palma
2006-Mar-09 15:15 UTC
[Asterisk-Users] Extracting info from the $EXTEN variable
Is there a way to access only certain positions in the $EXTEN variable?
I'd like to filter my international calls based on the destination country:
My dialplan looks like this (1XX0. is the international calling
convention for Chile)
exten => _1XX0.,1,Dial(SIP/${EXTEN:4}@external_provider)
But, I'd like to, depending on the destination country (digits 5 and
eventually 6 of EXTEN), route my calls for another provider, something like:
exten => _1XX0.,1,GotoIf(${EXTEN[5-6]} == certain_pattern)?2,3)
exten => _1XX0.,2,Dial(SIP/${EXTEN:4}@external_provider1)
exten => _1XX0.,3,Dial(SIP/${EXTEN:4}@external_provider2)
How can I do that? I was looking the documentation, but it only speaks
of stripping digits from the extension, not to selecting a range.
Thanks a lot for your help.
--
Atly.
?lvaro Palma
you will have to do that in the gotoif statement, something like this:
exten => _X.,1,GotoIf($[${EXTEN:2:1}=1]?20)
exten => _X.,2,GotoIf($[${EXTEN:2:1}=2]?30)
exten => just add your own here
the above will got to priority 20 if the 3rd digit is a 1, and to 30
if the 3rd digit is a 2.
On 3/9/06, ?lvaro Palma <apalma@opschile.cl>
wrote:> Is there a way to access only certain positions in the $EXTEN variable?
> I'd like to filter my international calls based on the destination
country:
>
> My dialplan looks like this (1XX0. is the international calling
> convention for Chile)
>
> exten => _1XX0.,1,Dial(SIP/${EXTEN:4}@external_provider)
>
> But, I'd like to, depending on the destination country (digits 5 and
> eventually 6 of EXTEN), route my calls for another provider, something
like:
>
> exten => _1XX0.,1,GotoIf(${EXTEN[5-6]} == certain_pattern)?2,3)
> exten => _1XX0.,2,Dial(SIP/${EXTEN:4}@external_provider1)
> exten => _1XX0.,3,Dial(SIP/${EXTEN:4}@external_provider2)
>
> How can I do that? I was looking the documentation, but it only speaks
> of stripping digits from the extension, not to selecting a range.
>
> Thanks a lot for your help.
>
> --
> Atly.
> ?lvaro Palma
>
> _______________________________________________
> --Bandwidth and Colocation provided by Easynews.com --
>
> Asterisk-Users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
At 03:39 PM 03/09/2006, you wrote:>you will have to do that in the gotoif statement, something like this: >exten => _X.,1,GotoIf($[${EXTEN:2:1}=1]?20) >exten => _X.,2,GotoIf($[${EXTEN:2:1}=2]?30)Close, but it needs spaces around the equal signs, like: exten => _X.,1,GotoIf($[${EXTEN:2:1} = 1]?20) exten => _X.,2,GotoIf($[${EXTEN:2:1} = 2]?30) Or if you want it to not crash if EXTEN is empty: exten => _X.,1,GotoIf($["${EXTEN:2:1}" = "1"]?20) exten => _X.,2,GotoIf($["${EXTEN:2:1}" = "2"]?30) Ira -- No virus found in this outgoing message. Checked by AVG Anti-Virus. Version: 7.1.375 / Virus Database: 268.2.1/278 - Release Date: 03/09/2006