[asterisk-users] Basic GotoIf question

Noah Engelberth Noah at directlinkcomputers.com
Sat Aug 25 02:21:20 CDT 2012



-----Original Message-----
From: asterisk-users-bounces at lists.digium.com [mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Markus
Sent: Saturday, August 25, 2012 3:08 AM
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: [asterisk-users] Basic GotoIf question

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()



More information about the asterisk-users mailing list