Unable to create channel variable

I’m unable to create a channel variable defined in the dial plan to be accessed in the script. My extensions.conf is given below

[b][internal]
exten => 100,1,Macro(DialFunction,${EXTEN})
exten => 101,1,Macro(DialFunction,${EXTEN})
exten => 500,1,VoiceMailMain(@internal)
exten => 600,1,MeetMe(600,1,54321)
exten => t,1,Hangup()

[macro-DialFunction]
exten => s,1,Answer()
exten => s,n,Set(myvariable=1000)
exten => s,n,agi(agi-test.agi)
exten => s,n,Dial(SIP/${ARG1},5,rL(${myvariable}))
exten => s,n,VoiceMail(u${ARG1}@internal)
exten => s,n,Hangup()
exten => s,102,Playback(tt-allbusy)
exten => s,n,VoiceMail(b${ARG1}@internal)
exten => s,n,Hangup()
[/b]

and the sample script is as

[b]#!/usr/bin/perl
use strict;

$|=1;

Setup some variables

my %AGI; my $tests = 0; my $fail = 0; my $pass = 0;

while() {
chomp;
last unless length($);
if (/^agi
(\w+):\s+(.*)$/) {
$AGI{$1} = $2;
}
}

$AGI{accountcode}++;

print STDERR “AGI Environment Dump:\n”;
foreach my $i (sort keys %AGI) {
print STDERR " – $i = $AGI{$i}\n";
}

sub checkresult {
my ($res) = @_;
my $retval;
$tests++;
chomp $res;
if ($res =~ /^200/) {
$res =~ /result=(-?\d+)/;
if (!length($1)) {
print STDERR “FAIL ($res)\n”;
$fail++;
} else {
print STDERR “PASS ($1)\n”;
$pass++;
}
} else {
print STDERR “FAIL (unexpected result ‘$res’)\n”;
$fail++;
}
}
print STDERR “1. Testing ‘sendfile’…”;
print “STREAM FILE beep “”\n”;
my $result = ;
&checkresult($result);

print STDERR “2. Testing ‘sendtext’…”;
print “SEND TEXT “hello world”\n”;
my $result = ;
&checkresult($result);

print STDERR “3. Testing ‘sendimage’…”;
print “SEND IMAGE asterisk-image\n”;
my $result = ;
&checkresult($result);

print STDERR “4. Testing ‘saynumber’…”;
print “SAY NUMBER 192837465 “”\n”;
my $result = ;
&checkresult($result);

print STDERR “5. Testing ‘waitdtmf’…”;
print “WAIT FOR DIGIT 1000\n”;
my $result = ;
&checkresult($result);

print STDERR “6. Testing ‘record’…”;
print “RECORD FILE testagi gsm 1234 3000\n”;
my $result = ;
&checkresult($result);

print STDERR “6a. Testing ‘record’ playback…”;
print “STREAM FILE testagi “”\n”;
my $result = ;
&checkresult($result);

print STDERR “================== Complete ======================\n”;
print STDERR “$tests tests completed, $pass passed, $fail failed\n”;
print STDERR “==================================================\n”;

[/b]

after the above mentioned configuration, it doesn’t show me the variable i defined in the dial plan. Please tell me where i’m wrong. It shows the following output.

AGI Tx >> agi_request: agi-test.agi
AGI Tx >> agi_channel: SIP/101-08161020
AGI Tx >> agi_language: en
AGI Tx >> agi_type: SIP
AGI Tx >> agi_uniqueid: 1174990541.5
AGI Tx >> agi_callerid: 101
AGI Tx >> agi_calleridname: Arif Asim
AGI Tx >> agi_callingpres: 0
AGI Tx >> agi_callingani2: 0
AGI Tx >> agi_callington: 0
AGI Tx >> agi_callingtns: 0
AGI Tx >> agi_dnid: 100
AGI Tx >> agi_rdnis: unknown
AGI Tx >> agi_context: macro-DialFunction
AGI Tx >> agi_extension: s
AGI Tx >> agi_priority: 3
AGI Tx >> agi_enhanced: 0.0
AGI Tx >> agi_accountcode:
AGI Tx >> *CLI>
AGI Rx << STREAM FILE beep ""
AGI Tx >> 200 result=-1 endpos=160

Kindly resolve my problem and tell me what i’m missing. I’m newbie in Asterisk

Fixed it. I enabled “agi debug” command end found everything in front of my eyes. Thanks anyways.