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

Race Vanderdecken asteriskusers at codetyrant.com
Thu Feb 17 15:16:13 MST 2005


Hmmm,

I faintly recall having a similar "" problem a couple of months ago.

I think my solution was to assign the two strings to two separate
variables and then compare the variables.

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

ABC=("$[${CALLERIDNAME:0:4}"

XYZ="PRV:"

exten => s,3,GotoIf(ABC=XYZ?5)


NOTE: my syntax is not correct, and this code won't work if pasted
directly.
Also, remember to watch the " " spaces in exten => lines.


Race "The Tyrant" Vanderdecken

-----Original Message-----
From: asterisk-users-bounces at lists.digium.com
[mailto:asterisk-users-bounces at lists.digium.com] On Behalf Of Scott
Bussinger
Sent: Thursday, February 17, 2005 3:49 PM
To: 'Asterisk Users Mailing List - Non-Commercial Discussion'
Subject: [Asterisk-Users] Proper syntax for expression in GotoIf()
command

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!


_______________________________________________
Asterisk-Users mailing list
Asterisk-Users at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-users
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users





More information about the asterisk-users mailing list