[Asterisk-Users] SetVar on sample.call

DUSTIN WILDES dwildes at pabbankshares.com
Mon Aug 25 06:54:59 MST 2003


Hi all!!

Does anyone have a short example or even better - a working AGI script that uses "GET VARIABLE' from a /var/spool/asterisk/outgoing call that uses "SetVar"?
Here's what I've tried with no luck so far:


sample.call
=================

Channel:  SIP/1000
MaxRetries: 2
RetryTime: 60
WaitTime: 30

Application: Agi
Data:  playTasks.agi

Callerid:  Nightly Processor <(999) 888-777>

SetVar:  taskID=300   //This ID is queried from my mysql database so the playTasks.agi should be able to retreive this value to do another query to play information



playTasks.agi  (Derived from the agi-test.agi)
======================================
#!/usr/bin/perl
                                                                                                                                                                           
$|=1;
while(<STDIN>) {
        chomp;
        last unless length($_);
        if (/^agi_(\w+)\:\s+(.*)$/) {
                $AGI{$1} = $2;
        }
}
                                                                                                                                                                           
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 "GET VARIABLE taskID\n";
        $result = <STDIN>;
        $taskID = checkresult($result);
        print STDERR "TaskID:  $taskID\n";
        print STDERR "Result:  $result\n";
                                                                                                                                                                           
print "SAY NUMBER $taskID \"\"\n";
        $result = <STDIN>;
        checkresult($result);
======================================


I always get 'zero' played back at the prompt & the result(s) don't display my $taskID.
Anyone got any recommendations or how to fix it?


Thanks!!



More information about the asterisk-users mailing list