[asterisk-dev] Expression logic problem

Mueller, Alexander am at a-m-i.de
Mon Dec 21 09:35:50 CST 2009


Hello,

when using GotoIf, I always get "false" no matter whether the condition is true or not.

I need to filter calls with suppressed CALLERID, and I do so in the dialplan:

exten => 7058863,1,NoOp(incoming call for ${EXTEN} from ${CALLERID(num)})
exten => 7058863,n,GotoIf(${LEN(${CALLERID(num)})} = 0?blacklist:ok)

exten => 7058863,n(blacklist),NoOp(blocken!)
exten => 7058863,n,Voicemail(7058863,u)

exten => 7058863,n(ok),NoOp(OK, nicht geblockt)


-- Accepting call from '' to '7058863' on channel 0/1, span 1
    -- Executing [7058863 at default:1] NoOp("DAHDI/1-1", "incoming call for 7058863 from ") in new stack
    -- Executing [7058863 at default:2] GotoIf("DAHDI/1-1", "0 = 0?blacklist:ok") in new stack
    -- Goto (default,7058863,5)
    -- Executing [7058863 at default:5] NoOp("DAHDI/1-1", "OK, nicht geblockt") in new stack


No matter if I use
  LEN(${CALLERID(num)}) = 0
  ${LEN(${CALLERID(num)})} = 0
  $[LEN(${CALLERID(num)})] = 0

I would expect this to be true an jump to blacklist.
Interestingly, using

exten => 7058863,n,GotoIf(${LEN(${CALLERID(num)})} > 0?blacklist:ok)

yields no surprise:

Executing [7058863 at default:1] NoOp("DAHDI/1-1", "incoming call for 7058863 from ") in new stack
    -- Executing [7058863 at default:2] GotoIf("DAHDI/1-1", "0 > 0?blacklist:ok") in new stack
    -- Goto (default,7058863,5)
    -- Executing [7058863 at default:5] NoOp("DAHDI/1-1", "OK, nicht geblockt") in new stack

But then a test with

exten => 7058863,n,GotoIf(1 > 0?blacklist:ok)

yields the needed "true":

Accepting call from '' to '7058863' on channel 0/1, span 1
    -- Executing [7058863 at default:1] NoOp("DAHDI/1-1", "incoming call for 7058863 from ") in new stack
    -- Executing [7058863 at default:2] GotoIf("DAHDI/1-1", "1 > 0?blacklist:ok") in new stack
    -- Goto (default,7058863,3)
    -- Executing [7058863 at default:3] NoOp("DAHDI/1-1", "blocken!") in new stack
    -- Executing [7058863 at default:4] VoiceMail("DAHDI/1-1", "7058863,u") in new stack

What is this ? The result of "LEN" seems to be no numeric value, and it cannot be made so for example by wrapping it into "$[]".

Interpreting it as a string, and comparing it to a zero in quotation marks ("0") also doesn't make the comparison true.

Thanks for help.

Alex


-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-dev/attachments/20091221/58e441b3/attachment-0001.htm 


More information about the asterisk-dev mailing list