Set and Get variable using agi


I m having Asterisk installed on my CentOS release 5.6 (Final).

I want to pass variable from dialplan to agi and when agi pass variable, I want to use that variable back on dialplan. I m doing it using below of my sample agi script. But I m getting below error :


use DBI;
use Asterisk::AGI;
$AGI = new Asterisk::AGI;

my %input = $AGI->ReadParse();
my $dest = $AGI->get_variable(“CHANNEL”);

$AGI->exec(‘Set’,‘TEST_VAR’, $TEST_VAR);

$AGI->set_variable(‘TEST_VAR’, $TEST_VAR);


Below is my dialplan :

CLI output :

[quote] == Manager ‘sendcron’ logged off from
– Executing [12345@axiom-test:1] NoOp(“SIP/8001-00000081”, “============== INTERNAL USE ONLY =================”) in new stack
– Executing [12345@axiom-test:2] AGI(“SIP/8001-00000081”, “temp1.agi|SIP/8001-00000081”) in new stack
– Launched AGI Script /var/lib/asterisk/agi-bin/temp1.agi
– AGI Script Executing Application: (Set) Options: (TEST_VAR)
[Sep 18 10:59:02] WARNING[20713]: pbx.c:6075 pbx_builtin_setvar: Ignoring entry ‘TEST_VAR’ with no = (and not last ‘options’ entry)
[Sep 18 10:59:02] ERROR[20713]: utils.c:967 ast_carefulwrite: write() returned error: Broken pipe
– AGI Script temp1.agi completed, returning 0
– Executing [12345@axiom-test:3] Set(“SIP/8001-00000081”, “TEST=”) in new stack
== Auto fallthrough, channel ‘SIP/8001-00000081’ status is ‘UNKNOWN’[/quote]

-Thank You.

The first error is because you are missing th “=” and probably have too many parameters.

The second error is because you didn’t read all the AGI responses.

I would gess the variable isn’t set because it isn’t set in the AGI script.