在拨号计划中使用 GotoIf 时出错
我正在尝试实现一个需要与用户交互的复杂拨号计划。基于这种交互,拨号方案跳转到另一部分。下面给出了一些示例代码:
[test]
;This is a test.
exten => 0,n(qa1),NoOp()
exten => 0,1,Verbose(1, "This is a test")
exten => 0,n,Set(USER_ANSWER=0)
exten => 0,n,Read(USER_ANSWER,,1,,2,10)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n,GotoIf($[$["${USER_ANSWER}"="1"] | $["${USER_ANSWER}"="2"]]?eval1:qa1)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n(eval),NoOp()
...
运行上述代码时,星号在评估上述
GotoIf
条件后挂起。错误信息如下:-- 用户输入“1” -- 在新堆栈中执行 [0@test:19] Verbose("DAHDI/13-1", "1, "User keyed in 1"") “用户输入1” -- 在新堆栈中执行 [0@test:20] GotoIf("DAHDI/13-1", "1?eval1:qa1") -- 转到(测试,0,21) -- 在新堆栈中执行 [0@test:21] NoOp("DAHDI/13-1", "") [Jan 25 10:47:48] WARNING[29738]: pbx.c:3677 pbx_extension_helper: No application 'If' for extension (test, 0, 22)
我的问题是:
- 该错误消息是什么意思?
- 我该如何纠正它才能正常工作?
I am trying to implement a complex dialplan that requires interaction with the user. Based on this interaction, the dialplan jumps to another part. Some sample code is given below:
[test]
;This is a test.
exten => 0,n(qa1),NoOp()
exten => 0,1,Verbose(1, "This is a test")
exten => 0,n,Set(USER_ANSWER=0)
exten => 0,n,Read(USER_ANSWER,,1,,2,10)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n,GotoIf($[$["${USER_ANSWER}"="1"] | $["${USER_ANSWER}"="2"]]?eval1:qa1)
exten => 0,n,Verbose(1, "User keyed in ${USER_ANSWER}")
exten => 0,n(eval),NoOp()
...
On running the above code, asterisk hangs up after evaluating the
GotoIf
condition above. The error messages are as follows:-- User entered '1'
-- Executing [0@test:19] Verbose("DAHDI/13-1", "1, "User keyed in 1"") in new stack
"User keyed in 1"
-- Executing [0@test:20] GotoIf("DAHDI/13-1", "1?eval1:qa1") in new stack
-- Goto (test,0,21)
-- Executing [0@test:21] NoOp("DAHDI/13-1", "") in new stack
[Jan 25 10:47:48] WARNING[29738]: pbx.c:3677 pbx_extension_helper: No application 'If' for extension (test, 0, 22)
My questions are:
- What does that error message mean?
- How can I correct it so it works?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
GotoIf
被正确调用。标签eval1
后面有If
语句。 Asterisk 没有If
语句。将If
语句替换为ExecIf
就可以了。您可以通过在 Asterisk CLI 提示符下键入以下命令来找出可用的命令:核心显示应用程序<此处的命令名称>
如果上述命令返回输出,则该命令可用,否则不可用。
The
GotoIf
is invoked correctly. The labeleval1
hasIf
statements following it. Asterisk does not haveIf
statements. Replacing theIf
statements withExecIf
did the trick. One can figure out what commands are available by typing, at the Asterisk CLI prompt, the following command:core show application <command name here>
If the above command returns an output, then that command is available, else not.