Using an example provided by "The Hitchhiker's Guide to Asterisk", I made the following addition to my extensions.conf file: [inbound-analog] exten => s,1,Wait(1) exten => s,2,SetVar(counter=0) exten => s,3,Answer() exten => s,4,Wait(1) exten => s,5,DigitTimeout(15) exten => s,6,ResponseTimeout(10) exten => s,7,BackGround(pls-entr-num-uwish2-call) exten => t,1,SetVar(counter=[${counter}+1]) exten => t,2,Gotoif([${counter}<3]?s,7:h,1) exten => i,1,Playback(invalid) exten => h,1,hangup() The hope would be that the "pls-entr-num-uwish2-call" message would be offered up to incoming calls 3 times if the caller times out (10 seconds) and then hangup. However the call hangs up 10 seconds after the first playing of "pls-entr-num-uwish2-call". My asterisk log shows: -- Executing Wait("Zap/99-1", "1") in new stack -- Executing SetVar("Zap/99-1", "counter=0") in new stack -- Executing Answer("Zap/99-1", "") in new stack -- Executing Wait("Zap/99-1", "1") in new stack -- Executing DigitTimeout("Zap/99-1", "15") in new stack -- Set Digit Timeout to 15 -- Executing ResponseTimeout("Zap/99-1", "10") in new stack -- Set Response Timeout to 10 -- Executing BackGround("Zap/99-1", "pls-entr-num-uwish2-call") in new stack -- Playing 'pls-entr-num-uwish2-call' (language 'en') -- Timeout on Zap/99-1 == CDR updated on Zap/99-1 -- Executing SetVar("Zap/99-1", "counter=[0+1]") in new stack -- Executing GotoIf("Zap/99-1", "[[0+1]<3]?s|7:h|1") in new stack -- Goto (inbound-analog,h,1) -- Executing Hangup("Zap/99-1", "") in new stack == Spawn extension (inbound-analog, h, 1) exited non-zero on 'Zap/99-1' -- Executing Hangup("Zap/99-1", "") in new stack == Spawn extension (inbound-analog, h, 1) exited non-zero on 'Zap/99-1' -- Hungup 'Zap/99-1' It looks to me as if the Gotoif thinks that [0+1] is greater than or equal to 3 and therefore jumps to hangup. Am I missing something here? -- Steve Woolley IT Manager ADS Telecom, Inc. 59 Skyline Drive Suite 1250 Lake Mary, Florida 32746 Phone: (407)682-6226 x1110 Fax: (407)682-3455 Cell: (321)229-5311 swoolley@adstelecom.com www.adstelecom.com
<snip>> -- Executing SetVar("Zap/99-1", "counter=[0+1]") > in new stack > -- Executing GotoIf("Zap/99-1", > "[[0+1]<3]?s|7:h|1") in new stack > -- Goto (inbound-analog,h,1)<snip>> > It looks to me as if the Gotoif thinks that [0+1] is > greater than or > equal to 3 and therefore jumps to hangup. > > Am I missing something here? >I apologize in advance for the stupid question, but is it at all possible that counter is being evaluated in a string context either in the additionor the GoToIf command? (One quick way to check that is to see what happens if you put a second addition in right after the first, and see if you get '2', or '[[0+1]+1]'). Shaun __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail
Stefan Tichy
2004-Jul-12 09:48 UTC
[Asterisk-Users] Re: Gogoif with variables acting funny?
On Mon, Jul 12, 2004 at 10:51:24AM -0400, Steve Woolley wrote:> exten => t,1,SetVar(counter=[${counter}+1]) > exten => t,2,Gotoif([${counter}<3]?s,7:h,1)You need $2 Example: SetVar(lala=$[1 + 2]); GotoIf($[${CALLERIDNUM} = 303]?3:2) http://www.voip-info.org/wiki-Asterisk+Expressions http://www.voip-info.org/wiki-Asterisk+cmd+GotoIf -- Stefan Tichy <asterisk@pi4tel.de>
Are you using the lastest cvs? If not you have a broken gotoif... bkw> -----Original Message----- > From: asterisk-users-admin@lists.digium.com [mailto:asterisk-users- > admin@lists.digium.com] On Behalf Of Steve Woolley > Sent: Monday, July 12, 2004 9:51 AM > To: asterisk-users@lists.digium.com > Subject: [Asterisk-Users] Gogoif with variables acting funny? > > Using an example provided by "The Hitchhiker's Guide to Asterisk", I > made the following addition to my extensions.conf file: > > [inbound-analog] > exten => s,1,Wait(1) > exten => s,2,SetVar(counter=0) > exten => s,3,Answer() > exten => s,4,Wait(1) > exten => s,5,DigitTimeout(15) > exten => s,6,ResponseTimeout(10) > exten => s,7,BackGround(pls-entr-num-uwish2-call) > > exten => t,1,SetVar(counter=[${counter}+1]) > exten => t,2,Gotoif([${counter}<3]?s,7:h,1) > > exten => i,1,Playback(invalid) > > exten => h,1,hangup() > > The hope would be that the "pls-entr-num-uwish2-call" message would be > offered up to incoming calls 3 times if the caller times out (10 > seconds) and then hangup. However the call hangs up 10 seconds after the > first playing of "pls-entr-num-uwish2-call". > > My asterisk log shows: > > -- Executing Wait("Zap/99-1", "1") in new stack > -- Executing SetVar("Zap/99-1", "counter=0") in new stack > -- Executing Answer("Zap/99-1", "") in new stack > -- Executing Wait("Zap/99-1", "1") in new stack > -- Executing DigitTimeout("Zap/99-1", "15") in new stack > -- Set Digit Timeout to 15 > -- Executing ResponseTimeout("Zap/99-1", "10") in new stack > -- Set Response Timeout to 10 > -- Executing BackGround("Zap/99-1", "pls-entr-num-uwish2-call") in > new stack > -- Playing 'pls-entr-num-uwish2-call' (language 'en') > -- Timeout on Zap/99-1 > == CDR updated on Zap/99-1 > -- Executing SetVar("Zap/99-1", "counter=[0+1]") in new stack > -- Executing GotoIf("Zap/99-1", "[[0+1]<3]?s|7:h|1") in new stack > -- Goto (inbound-analog,h,1) > -- Executing Hangup("Zap/99-1", "") in new stack > == Spawn extension (inbound-analog, h, 1) exited non-zero on > 'Zap/99-1' > -- Executing Hangup("Zap/99-1", "") in new stack > == Spawn extension (inbound-analog, h, 1) exited non-zero on > 'Zap/99-1' > -- Hungup 'Zap/99-1' > > It looks to me as if the Gotoif thinks that [0+1] is greater than or > equal to 3 and therefore jumps to hangup. > > Am I missing something here? > > -- > Steve Woolley > IT Manager > ADS Telecom, Inc. > 59 Skyline Drive > Suite 1250 > Lake Mary, Florida 32746 > > Phone: (407)682-6226 x1110 > Fax: (407)682-3455 > Cell: (321)229-5311 > > swoolley@adstelecom.com > www.adstelecom.com > _______________________________________________ > Asterisk-Users mailing list > Asterisk-Users@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
Steve Woolley
2004-Jul-12 11:32 UTC
[Asterisk-Users] Re: Gogoif with variables acting funny?
It is possible and probably most likely that it is being interpreted as a string. The real question is though, why? I believe it is syntactically correct.> Date: Mon, 12 Jul 2004 09:26:02 -0700 (PDT) > From: Shaun Dawson <bigchiefscd@yahoo.com> > Subject: Re: [Asterisk-Users] Gogoif with variables acting funny? > To: asterisk-users@lists.digium.com > Reply-To: asterisk-users@lists.digium.com > > > <snip> > > > -- Executing SetVar("Zap/99-1", "counter=[0+1]") > > in new stack > > -- Executing GotoIf("Zap/99-1", > > "[[0+1]<3]?s|7:h|1") in new stack > > -- Goto (inbound-analog,h,1) > > <snip> > > > > > It looks to me as if the Gotoif thinks that [0+1] is > > greater than or > > equal to 3 and therefore jumps to hangup. > > > > Am I missing something here? > > > > I apologize in advance for the stupid question, but > is it at all possible that counter is being evaluated > in a string context either in the additionor the > GoToIf command? (One quick way to check that is to > see what happens if you put a second addition in right > after the first, and see if you get '2', or > '[[0+1]+1]'). > > > Shaun-- Steve Woolley IT Manager ADS Telecom, Inc. 59 Skyline Drive Suite 1250 Lake Mary, Florida 32746 Phone: (407)682-6226 x1110 Fax: (407)682-3455 Cell: (321)229-5311 swoolley@adstelecom.com www.adstelecom.com
$[expr1 operator expr2] Spaces (and lack of spaces) are important. There is no space between the opening [ and expr1, or between expr2 and the closing ]. But you do need spaces separating expr1 from operator, and separating operator from expr2. -----Original Message----- From: Steve Woolley [mailto:swoolley@adstelecom.com] Sent: Monday, July 12, 2004 12:33 PM To: asterisk-users@lists.digium.com Subject: [Asterisk-Users] Re: Gogoif with variables acting funny? It is possible and probably most likely that it is being interpreted as a string. The real question is though, why? I believe it is syntactically correct.> Date: Mon, 12 Jul 2004 09:26:02 -0700 (PDT) > From: Shaun Dawson <bigchiefscd@yahoo.com> > Subject: Re: [Asterisk-Users] Gogoif with variables acting funny? > To: asterisk-users@lists.digium.com > Reply-To: asterisk-users@lists.digium.com > > > <snip> > > > -- Executing SetVar("Zap/99-1", "counter=[0+1]") > > in new stack > > -- Executing GotoIf("Zap/99-1", > > "[[0+1]<3]?s|7:h|1") in new stack > > -- Goto (inbound-analog,h,1) > > <snip> > > > > > It looks to me as if the Gotoif thinks that [0+1] is > > greater than or > > equal to 3 and therefore jumps to hangup. > > > > Am I missing something here? > > > > I apologize in advance for the stupid question, but > is it at all possible that counter is being evaluated > in a string context either in the additionor the > GoToIf command? (One quick way to check that is to > see what happens if you put a second addition in right > after the first, and see if you get '2', or > '[[0+1]+1]'). > > > Shaun-- Steve Woolley IT Manager ADS Telecom, Inc. 59 Skyline Drive Suite 1250 Lake Mary, Florida 32746 Phone: (407)682-6226 x1110 Fax: (407)682-3455 Cell: (321)229-5311 swoolley@adstelecom.com www.adstelecom.com _______________________________________________ Asterisk-Users mailing list Asterisk-Users@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
Steve Murphy
2004-Jul-12 23:13 UTC
[Asterisk-Users] Re: Gogoif with variables acting funny?
Andrew Kohlsmith wrote:> On Monday 12 July 2004 18:44, Ed Pringle wrote: > > $[expr1 operator expr2] > > > > Spaces (and lack of spaces) are important. There is no space > between the > > opening [ and expr1, or between expr2 and the closing ]. But you do > need > > spaces separating expr1 from operator, and separating operator from > expr2. > > Any particular reason why it's so picky about spaces, especially > between the > [] and exprs? Seems like a minor bug to me. > > -A.I added code to improve the parser, to a degree, a number of weeks ago. It is in CVS right now. Basically, it made it so it didn't care how many spaces were between tokens (as long as there is at least one), or at the beginning or end of the string to be evaluated. It also improved the error messages that are sent to the log (see /var/log/asterisk/messages). And, I made it use double quotes to force a string token... even if the string contains spaces. It's all documented in the asterisk/doc/README.variables. I was very tempted to change it so that it used a lexer-- like lex, perfect hash, etc, etc.... but just didn't have the time. It'd be a big change. The lexical analysis is real simple. it uses a space, basically, to separate tokens. And that's it! No space? it's all one token. murf
Steve Woolley
2004-Jul-13 05:01 UTC
[Asterisk-Users] Re: Gogoif with variables acting funny?
So far I have tried various forms of the expression including: exten => t,2,Gotoif,$[${counter} < 3]?s|7:h|1 exten => t,2,Gotoif([${counter} < 3]?s,7:h,1) exten => t,2,Gotoif([ ${counter} < 3 ]?s,7:h,1) exten => t,2,Gotoif([ ${counter} < 3] ? s,7 : h,1) With none of the desired results. It always jumps to hangup: -- Goto (inbound-analog,h,1) The most interesting result was from the 1st one: exten => t,2,Gotoif,$[${counter} < 3]?s|7:h|1 In the log it showed: -- Executing SetVar("Zap/99-1", "counter=[0+1]") in new stack -- Executing GotoIf("Zap/99-1", "0?s|7:h|1") in new stack -- Goto (inbound-analog,h,1) According to numerous installation guides, I need bison installed to process expressions within my extensions.conf. I am running RedHat Enterprise Linus 3.0 which says bison is installed. However it seems I am not properly processing the expressions, is their a config file or PATH variable that can be set or is their some other log file that would show a bison problem within asterisk? Andrew Kohlsmith wrote:> On Monday 12 July 2004 18:44, Ed Pringle wrote: > > $[expr1 operator expr2] > > > > Spaces (and lack of spaces) are important. There is no space > between the > > opening [ and expr1, or between expr2 and the closing ]. But you do > need > > spaces separating expr1 from operator, and separating operator from > expr2. > > Any particular reason why it's so picky about spaces, especially > between the > [] and exprs? Seems like a minor bug to me. > > -A.I added code to improve the parser, to a degree, a number of weeks ago. It is in CVS right now. Basically, it made it so it didn't care how many spaces were between tokens (as long as there is at least one), or at the beginning or end of the string to be evaluated. It also improved the error messages that are sent to the log (see /var/log/asterisk/messages). And, I made it use double quotes to force a string token... even if the string contains spaces. It's all documented in the asterisk/doc/README.variables. I was very tempted to change it so that it used a lexer-- like lex, perfect hash, etc, etc.... but just didn't have the time. It'd be a big change. The lexical analysis is real simple. it uses a space, basically, to separate tokens. And that's it! No space? it's all one token. murf --__--__-- _______________________________________________ Asterisk-Users mailing list Asterisk-Users@lists.digium.com http://lists.digium.com/mailman/listinfo/asterisk-users End of Asterisk-Users Digest -- Steve Woolley IT Manager ADS Telecom, Inc. 59 Skyline Drive Suite 1250 Lake Mary, Florida 32746 Phone: (407)682-6226 x1110 Fax: (407)682-3455 Cell: (321)229-5311 swoolley@adstelecom.com www.adstelecom.com