detecting intl. CLI with +

Home » Asterisk Users » detecting intl. CLI with +
Asterisk Users 3 Comments

Hello asterisk users,

I need to convert the CLI received according to national/international
format:

55-555-5555 to 055-555-5555 (add 0 in the beginning)
+55-55-555-5555 to +55-55-555-5555 (remains unchanged)

I put the following line in my dial plan:
exten => _X., n, Set(CALLERID(num)=${IF($[ ${CALLERID(num):0:1} =
“+”]?${CALLERID(num)}:0${CALLERID(num)})})

But I get these error messages:
[May 2 17:05:43] WARNING[1494]: ast_expr2.fl:468 ast_yyerror:
ast_yyerror(): syntax error: syntax error, unexpected ‘+’, expecting $end;
Input:
+ = “+”
^
[May 2 17:05:43] WARNING[1494]: ast_expr2.fl:472 ast_yyerror: If you have
questions, please refer to
https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
[May 2 17:05:43] WARNING[1494]: func_logic.c:192 acf_if: Syntax
IF(?[][:]) (expr must be non-null, and either or
must be non-null)
[May 2 17:05:43] WARNING[1494]: func_logic.c:193 acf_if: In this
case, =”, =’+55555555555′, and =’0+55555555555′

Can anyone suggest the proper syntax? I tried the + with no quotes, single
quotes ‘+’ and double quotes”+” and nothing worked.

Thanks

3 thoughts on - detecting intl. CLI with +

  • I think you need to “escape” the + “+”

    [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Michael
    Sent: Wednesday, May 02, 2012 11:20 AM

    Hello asterisk users,

    I need to convert the CLI received according to national/international
    format:

    55-555-5555 to 055-555-5555 (add 0 in the beginning)
    +55-55-555-5555 to +55-55-555-5555 (remains unchanged)

    I put the following line in my dial plan:
    exten => _X., n, Set(CALLERID(num)=${IF($[ ${CALLERID(num):0:1} =
    “+”]?${CALLERID(num)}:0${CALLERID(num)})})

    But I get these error messages:
    [May 2 17:05:43] WARNING[1494]: ast_expr2.fl:468 ast_yyerror:
    ast_yyerror(): syntax error: syntax error, unexpected ‘+’, expecting $end;
    Input:
    + = “+”
    ^
    [May 2 17:05:43] WARNING[1494]: ast_expr2.fl:472 ast_yyerror: If you have
    questions, please refer to
    https://wiki.asterisk.org/wiki/display/AST/Channel+Variables
    [May 2 17:05:43] WARNING[1494]: func_logic.c:192 acf_if: Syntax
    IF(?[][:]) (expr must be non-null, and either or
    must be non-null)
    [May 2 17:05:43] WARNING[1494]: func_logic.c:193 acf_if: In this
    case, =”, =’+55555555555′, and =’0+55555555555′

    Can anyone suggest the proper syntax? I tried the + with no quotes, single
    quotes ‘+’ and double quotes”+” and nothing worked.

    Thanks

  • If you have quotes on one side of the = sign, then you need quotes on the other side. In your dialplan line you are comparing + with “+”. A plus sign is not equal to quote plus sign quote

    exten => _X., n, Set(CALLERID(num)=${IF($[“${CALLERID(num):0:1}” = “+”]?${CALLERID(num)}:0${CALLERID(num)})})