[asterisk-users] Basic GotoIf question

Markus universe at truemetal.org
Sat Aug 25 11:42:13 CDT 2012


Am 25.08.2012 09:21, schrieb Noah Engelberth:
>
> Hi all,
> on Asterisk 1.4.21 I'm trying to block, that means directly hang up on, several inbound caller ID's like this:
> exten => 5555,1,GotoIf($["${CALLERID(num)}" != "6666"]?pass) exten => 5555,n,GotoIf($["${CALLERID(num)}" != "7777"]?pass) exten => 5555,n,GotoIf($["${CALLERID(num)}" != "8888"]?pass) exten => 5555,n,Hangup exten => 5555,n(pass),Set... everything from here on works.
> When I'm calling with caller ID 6666 I get hung up. When I'm calling from 7777 or 8888 I get connected.
> That means on the first GotoIf match the remaining GotoIf's are ignored.
> How can I avoid that?
> I'm a bit surprised, because "Example 3" at http://www.voip-info.org/wiki/view/Asterisk+cmd+GotoIf shows that it should actually be working.
> A few more questions - the doc link that I just mentioned shows:
> " GotoIf(condition?label1[[:label2])"
> What is the [[ before :label2? There are two opening square brackets, but just one ] closing? Is that a typo?
> Also, the doc shows:
> " GotoIf(condition?[label1]:label2)"
> Why is label1 in square brackets and label2 isn't?
> I'm confused. :)
> Thanks so much!
> Markus
>
> ---
>
> You need to run your logic the other way. What you're doing now is "if it's not CallerID A, pass it through and accept"
>
> So change to:
>
> exten => 5555,1,GotoIf($["${CALLERID(num)}" = "6666"]?hangup)
> exten => 5555,n,GotoIf($["${CALLERID(num)}" = "7777"]?hangup)
> exten => 5555,n,GotoIf($["${CALLERID(num)}" = "8888"]?hangup)
> exten => 5555,n,Set...
> ...more logic for accepted calls...
> exten => 5555,n(hangup),Hangup()

Thanks Noah! That worked.

Can anyone shed some light on:


A few more questions - the doc link that I just mentioned shows:

GotoIf(condition?label1[[:label2])

What are the [[ before :label2? There are two opening square brackets, 
but just one ] closing? Is that a typo?

Also, the doc shows:

GotoIf(condition?[label1]:label2)

Why is label1 in square brackets and label2 isn't?


Thanks!
Markus






More information about the asterisk-users mailing list