[Asterisk-Users] Problem with an AGI script. Going bald on this one.

Mike Diehl (Encrypted email preferred) mdiehl at diehlnet.com
Wed Nov 2 20:45:18 MST 2005


Hi all.

I'm trying to write an AGI script to do some caller-id processing.  It was 
butchered from a script I found on the Web.  Essentially, it takes the CID 
from *, looks up the phone number from www.whitepages.com displays it in 
various ways, stores it in a local database as a cache, then returns to 
Asterisk.

It works from the command line:
=========================================================
dominion agi-bin # ./supercallerid.pl 5058814639

SET VARIABLE "name" "Moneysworth Automotive Incorporated"
SET VARIABLE "number" "5058814639"
=========================================================

(not a plug, just an example.)

However, it doesn't work from *.

The script can be downloaded from http://www.diehlnet.com/supercallerid.pl

I call the script from a macro:
=========================================================
[macro-send_cid]
exten => s,1,setvar(name=${CALLERID})
exten => s,2,setvar(number=${CALLERIDNUM})
exten => s,3,noop("${CALLERIDNUM} -> ${number}")
exten => s,4,agi(supercallerid.agi)
exten => s,5,setcidnum(${number})
exten => s,6,setcidname(${name})
exten => s,7,noop("${name} -> ${number}")
=========================================================

And I have an extension to test it with:
=========================================================
exten => 669,1,answer
exten => 669,2,macro(send_cid)
exten => 669,3,hangup
=========================================================

To test it, I restart Asterisk, set verbose to 15 and turn agi debugging on:
=========================================================ebut 
dominion*CLI> restart now
dominion*CLI>
Disconnected from Asterisk server
Attempting to reconnect for 30 seconds
Reconnect succeeded after 0.050 seconds
Asterisk 1.0.9, Copyright (C) 1999-2004 Digium.
Written by Mark Spencer <markster at digium.com>
dominion*CLI> set verbose 15
Verbosity was 0 and is now 15
dominion*CLI> agi debug
AGI Debugging Enabled
dominion*CLI> 
=========================================================ebut 

Then when I dial extension 669, I get:
=========================================================ebut
    -- Accepting AUTHENTICATED call from 10.0.1.5, requested format = 4, 
actual format = 2
    -- Executing Answer("IAX2/mike_diehl at mike_diehl/4", "") in new stack
    -- Executing Macro("IAX2/mike_diehl at mike_diehl/4", "send_cid") in new 
stack
    -- Executing SetVar("IAX2/mike_diehl at mike_diehl/4", "name=Mike Diehl 
<111>") in new stack
    -- Executing SetVar("IAX2/mike_diehl at mike_diehl/4", "number=111") in new 
stack
    -- Executing NoOp("IAX2/mike_diehl at mike_diehl/4", ""111 -> 111"") in new 
stack
    -- Executing AGI("IAX2/mike_diehl at mike_diehl/4", "supercallerid.agi") in 
new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/supercallerid.agi
AGI Tx >> agi_request: supercallerid.agi
AGI Tx >> agi_channel: IAX2/mike_diehl at mike_diehl/4
AGI Tx >> agi_language: en
AGI Tx >> agi_type: IAX2
AGI Tx >> agi_uniqueid: 1130989206.0
AGI Tx >> agi_callerid: Mike Diehl <111>
AGI Tx >> agi_dnid: 669
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: macro-send_cid
AGI Tx >> agi_extension: s
AGI Tx >> agi_priority: 4
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >>
    -- AGI Script supercallerid.agi completed, returning 0
    -- Executing SetCIDNum("IAX2/mike_diehl at mike_diehl/4", "111") in new stack
    -- Executing SetCIDName("IAX2/mike_diehl at mike_diehl/4", "Mike Diehl 
<111>") in new stack
    -- Executing NoOp("IAX2/mike_diehl at mike_diehl/4", ""Mike Diehl <111> -> 
111"") in new stack
    -- Executing Hangup("IAX2/mike_diehl at mike_diehl/4", "") in new stack
  == Spawn extension (family, 669, 3) exited non-zero on 
'IAX2/mike_diehl at mike_diehl/4'
    -- Hungup 'IAX2/mike_diehl at mike_diehl/4'

The problem is that it's not updating the Asterisk variables, nor is it 
updateing the database.  It's as if the perl script isn't even running.

I'm probably missing something simple, but I can't see it.  Any clues?

-- 
Mike
gpg key: http://diehlnet.com/~mdiehl/mdiehl.asc
83AD D927 758D 4BFC A800 0277 4B26 75A4 F0D1 C7EB




More information about the asterisk-users mailing list