Below is my python agi script. I'm trying to pass a value from dialplan to agi script and trying to print the value through the script. 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:
[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:
Stop asterisk service
Start asterisk service in console using asterisk -vvvgc
. This one is required to see error pipe of script.
in asterisk console enable agi debug
agi set debug on
run script
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.