[asterisk-users] Problem with AGI Script
Steve Edwards
asterisk.org at sedwards.com
Wed Nov 14 15:08:37 CST 2007
On Wed, 14 Nov 2007, Moises Silva wrote:
> what does agi debug says?
> what if you run the script from the command line and you fake the
> asterisk input?
"agi debug" (and syslog()) are the AGI developer's best friends :)
It shows the dialog between Asterisk and your AGI. Even if your AGI fails
to exist or execute, you will still see Asterisk setting up the AGI
environment for you, just none of the subsequent dialog.
I use the following script to fake the AGI environment:
# the standard AGI environment variables
echo "agi_accountcode: "
echo "agi_callerid: 1234567890"
echo "agi_calleridname: sedwards"
echo "agi_callingani2: 0"
echo "agi_callingpres: 0"
echo "agi_callingtns: 0"
echo "agi_callington: 0"
echo "agi_channel: SIP/201-09456478"
echo "agi_context: newline"
echo "agi_dnid: *"
echo "agi_enhanced: 0.0"
echo "agi_extension: *"
echo "agi_language: en"
echo "agi_priority: 3"
echo "agi_rdnis: unknown"
echo "agi_request: block-ani"
echo "agi_type: SIP"
echo "agi_uniqueid: 1195070681.28"
echo ""
# cruft specific to my AGI
# result for AGI command SET PRIORITY
echo "200 result=0"
# result for AGI command GET VARIABLE ANI
echo "200 result=1 (1234567890)"
# result for AGI command GET VARIABLE CALLINGANI2
echo "200 result=1 (0)"
# result for AGI command GET VARIABLE DATABASE-SERVER
echo "200 result=1 (pdb)"
# result for AGI command SET PRIORITY
echo "200 result=0"
# (end of agi-environment.sh)
This can be used as:
chmod +x agi-environment.sh
./agi-environment.sh | block-ani --debug
I use getopt_long() to parse the command line options and syslog() to
stash stuff to analyze after the fact.
You can even use gdb (if appropriate for your language) by saving the
output of the script and supplying it in the "r" command as:
./agi-environment.sh >agi-environment
gdb block-ani
(gdb) r --debug <agi-environment
Thanks in advance,
------------------------------------------------------------------------
Steve Edwards sedwards at sedwards.com Voice: +1-760-468-3867 PST
Newline Fax: +1-760-731-3000
More information about the asterisk-users
mailing list