简体   繁体   English

将值从Dialplan传递到python agi脚本

[英]passing values from dialplan to python agi script

Below is my python agi script. 以下是我的python agi脚本。 I'm trying to pass a value from dialplan to agi script and trying to print the value through the script. 我试图将一个值从Dialplan传递到agi脚本,并尝试通过该脚本打印该值。 Everything is working fine but the value is not passing to the script. 一切正常,但值未传递给脚本。 Please let me know if anything went wrong in it. 请让我知道其中是否有任何问题。

#!/usr/bin/python

from asterisk.agi import *

agi = AGI()

agi.verbose("python agi started")

phone_exten = agi.get_variable('PHONE_EXTEN')
agi.verbose("phone number",phone_exten)

agi.set_variable('EXT_CALLERID', '1')

Dailplan code: Dailplan代码:

[TEST]
exten => _X.,1,Goto(s,1)
exten => s,1,set(PHONE_EXTEN=0904)
exten => s,2,AGI(first.py,${PHONE_EXTEN})
exten => s,3,NoOp(${EXT_CALLERID})
exten => s,4,Hangup()

Output 产量

Connected to Asterisk 14.6.0 currently running on ip-172-31-18-90 (pid = 2539)
Core debug is still 10.
[Feb 20 12:54:39]   == Using SIP RTP CoS mark 5
[Feb 20 12:54:39]     -- Executing [0904@TEST:1] Goto("SIP/0904-00000004", "s,1") in new stack
[Feb 20 12:54:39]     -- Goto (TEST,s,1)
[Feb 20 12:54:39]     -- Executing [s@TEST:1] Set("SIP/0904-00000004", "PHONE_EXTEN=0904") in new stack
[Feb 20 12:54:39]     -- Executing [s@TEST:2] AGI("SIP/0904-00000004", "first.py,0904") in new stack
[Feb 20 12:54:39]     -- Launched AGI Script /var/lib/asterisk/agi-bin/first.py
[Feb 20 12:54:39]  first.py,0904: python agi started
[Feb 20 12:54:39]     -- <SIP/0904-00000004>AGI Script first.py completed, returning 0
[Feb 20 12:54:39]     -- Executing [s@TEST:3] NoOp("SIP/0904-00000004", "1") in new stack
[Feb 20 12:54:39]     -- Executing [s@TEST:4] Hangup("SIP/0904-00000004", "") in new stack
[Feb 20 12:54:39]   == Spawn extension (TEST, s, 4) exited non-zero on 'SIP/0904-00000004'

This question is seeking debug help, so it's off topic. 这个问题正在寻求调试帮助,因此不在主题之列。 But okay. 但是,好吧。

How to debug AGI script correctly: 如何正确调试AGI脚本:

  1. Stop asterisk service 停止星号服务

  2. Start asterisk service in console using asterisk -vvvgc . 使用asterisk -vvvgc在控制台中启动asterisk服务。 This one is required to see error pipe of script. 要查看脚本的错误管道,需要此代码。

  3. in asterisk console enable agi debug 在星号控制台中启用AGI调试

     agi set debug on 
  4. run script 运行脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM