Anurag Rana
2014-Sep-07 20:41 UTC
[asterisk-users] Pattern Extension not working in Dialplan
Hi, I created a dummy dialplan where I ask the user to enter the age. [macro-age] exten => s,1,Background(my/age) ;;Play recorded message to enter age exten => s,n,WaitExten(10) exten => _XX,1,Set(AGE=${EXTEN}) ;; this line is not executing, instead dialplan is terminating with error given below. exten => s,n,NoOp(${AGE}) exten => s,n,GotoIf($[${LEN(${AGE})} > 0]?notEmpty) exten => s,n,Goto(s,1) exten => s(notEmpty),n,Background(my/thank-you) exten => s,n,Wait(1) When I receive call and tries to enter the digits (86 lets say), it only accept just first digit and terminates even before considering second digit. Error message : WARNING[5726][C-0000000a]: pbx.c:6696 __ast_pbx_run: Invalid extension '8', but no rule 'i' or 'e' in context 'testmacro' Please suggest what might be wrong. Anurag Rana http://newbie42.blogspot.in/ -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140908/e8ea5bbb/attachment.html>
John Kiniston
2014-Sep-07 20:54 UTC
[asterisk-users] Pattern Extension not working in Dialplan
The first issue I see is you are attempting to insert your pattern match in the middle of your 's' extension, That's going to break your 's' extension. The second issue is that you are matching on XX which will match two digits, You need to match on _X instead if you are attempting to match on the number 8. I recommend you look into 'read' instead of trying to do a pattern match. On Sun, Sep 7, 2014 at 1:41 PM, Anurag Rana <anuragrana31189 at gmail.com> wrote:> Hi, > > I created a dummy dialplan where I ask the user to enter the age. > > [macro-age] > exten => s,1,Background(my/age) ;;Play recorded message to enter age > exten => s,n,WaitExten(10) > exten => _XX,1,Set(AGE=${EXTEN}) ;; this line is not executing, instead > dialplan is terminating with error given below. > exten => s,n,NoOp(${AGE}) > exten => s,n,GotoIf($[${LEN(${AGE})} > 0]?notEmpty) > exten => s,n,Goto(s,1) > exten => s(notEmpty),n,Background(my/thank-you) > exten => s,n,Wait(1) > > > When I receive call and tries to enter the digits (86 lets say), it only > accept just first digit and terminates even before considering second digit. > Error message : > WARNING[5726][C-0000000a]: pbx.c:6696 __ast_pbx_run: Invalid extension > '8', but no rule 'i' or 'e' in context 'testmacro' > > Please suggest what might be wrong. > > > Anurag Rana > http://newbie42.blogspot.in/ > > > > > -- > _____________________________________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > New to Asterisk? Join us for a live introductory webinar every Thurs: > http://www.asterisk.org/hello > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-- A human being should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects. ---Heinlein -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20140907/6962ba31/attachment.html>
A J Stiles
2014-Sep-08 08:12 UTC
[asterisk-users] Pattern Extension not working in Dialplan
On Sunday 07 Sep 2014, Anurag Rana wrote:> Hi, > > I created a dummy dialplan where I ask the user to enter the age. > > [macro-age] > exten => s,1,Background(my/age) ;;Play recorded message to enter age > exten => s,n,WaitExten(10) > exten => _XX,1,Set(AGE=${EXTEN}) ;; this line is not executing, instead > dialplan is terminating with error given below. > exten => s,n,NoOp(${AGE}) > exten => s,n,GotoIf($[${LEN(${AGE})} > 0]?notEmpty) > exten => s,n,Goto(s,1) > exten => s(notEmpty),n,Background(my/thank-you) > exten => s,n,Wait(1) > > > When I receive call and tries to enter the digits (86 lets say), it only > accept just first digit and terminates even before considering second > digit. Error message : > WARNING[5726][C-0000000a]: pbx.c:6696 __ast_pbx_run: Invalid extension > '8', but no rule 'i' or 'e' in context 'testmacro' > > Please suggest what might be wrong. > > > Anurag Rana > http://newbie42.blogspot.in/You would be better off jumping to a new context and building up your number, digit-by-digit as it is entered, in a channel variable. In your "s" extension, set your variable to an empty string; do a Background() and then WaitExten() for a digit to be entered. Have an extension _X to capture each digit and append it to the number so far. Then use a GotoIf() to jump to the WaitExten() statement if insufficient digits have been entered so far. You might also want a * extension to clear the number entered so far, if the user makes a mistake. If you need a written example, I might be able to dig something out later. -- AJS Note: Originating address only accepts e-mail from list! If replying off- list, change address to asterisk1list at earthshod dot co dot uk .