[Asterisk-Users] parsing to compare
Ed Devine
ncfm at airmail.net
Tue Apr 27 14:51:25 MST 2004
Admittedly this is probably pretty stupid of me, but there are just some things I can't understand by reading documentation. Any suggestions or recommendations about how to handle my problem are greatly appreciated. I'm trying to achieve the same functionality as my Nortel PBX, without rewriting much 'C' code.
In my dialplan I'd like to compare two variables as a means of getting around some of the troubles I've experienced in authenticating users, or with using Disa (primarily the requirement that a '#' be sent to terminate the authorization field). One variable (AUTHCODE shown below) is a series of digits entered by the caller once asterisk has answered and returned dialtone. I want to compare this variable to a variable already stored in ${CIDNAME} and, depending on the results of the comparison (i.e. if it's a match proceed, if not or if no value or '0' is found, branch to another context or simply to jump to an extension in the present context, or hangup
Everytime I've tried (using gotoif as an example) I get a parsing error; or the program allows everything through.
Think of the process as being like Disa, except you don't send the '#'
I've been noodling around with code that is pretty much as follows:
[main2]
exten => _XXXXXXX9XXXXXXXXXX,1,SetVar(AUTHCODE=${EXTEN:0:7})
'Calls coming in to '*' from outside are answered and sent here. The Caller recieves PlayInterruptibleTones(dial)
'and begins entering digits. The first seven are moved to the AUTHCODE variable for comparison.
exten => _XXXXXXX9XXXXXXXXXX,2,dbget(${CIDNAME} ${AUTHCODE})
'I do a dbget to retrieve the CIDNAME if one exists that matches AUTHCODE
exten => _XXXXXXX9XXXXXXXXXX,3,SetCIDName(${CIDNAME})
'I do this just so I don't have to screw around with the ast_expr.y: error or implementing
'the 'foo trick' to test for an empty value when using GoToif.
exten => _XXXXXXX9XXXXXXXXXX,4,Gotoif(${CIDNAME} = 228XXXX)?|1:5
'This is just one of the seemingly hundreds of options I've tried just to see if
'I could get the Gotoif to pass the call if it met the requirements, or fail if it didn't
exten => _XXXXXXX9XXXXXXXXXX,5,dial(zap/g3/${EXTEN:7:18})
'This is where I send the actual called number digits to the channel
exten => _XXXXXXX9XXXXXXXXXX,6,hangup
exten => s,1,answer
exten => s,2,Playinterruptibletones(dial)
exten => i,1,Congestion
exten => i,2,Hangup
exten => t,1,Congestion
exten => t,2,Hangup
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20040427/2b175733/attachment.htm
More information about the asterisk-users
mailing list