[Asterisk-Users] Proper syntax for expression in GotoIf() command

Scott Bussinger scottb at opto-pps.com
Thu Feb 17 13:48:31 MST 2005


I'd like some suggestions on the proper way to format a line in my
extensions.conf file.

In our office, most calls are sent to a group of extensions and whoever is
available answers the call. What I'd like to do is prefix the caller ID with
PRV: for those calls that are sent directly to a particular extension rather
than the group extension. That's easy enough:

	exten => s,4,SetCallerID(PRV:${CALLERIDNAME} <${CALLERIDNUM}>)

The problem is that I'd like to avoid adding an additional PRV: to the
caller id if it's already there (happens when a call comes in to a
particular extension and then gets transferred to another extension -- looks
like PRV:PRV:callerid).  I tried this:

	exten => s,3,GotoIf("$[${CALLERIDNAME:0:4}" = "PRV:"]?5)

In an attempt to see if the first four letters of the callerid are "PRV:".
The problem is I then get an error that looks like:

Feb 17 12:45:43 WARNING[10988]: ast_expr.y:475 ast_yyerror: ast_yyerror():
syntax error: syntax error; Input:
PRV:" = "PRV:"

What's happening is that the CALLERID strings have embedded quotes in them
and the extra quotes confuse the parsing of the expression. Is there some
better way to put in this line that avoids the problem? I've tried various
variations but nothing really works right.

Thanks!





More information about the asterisk-users mailing list