Dear Asterisk Nation,

I am attempting to write a perl AGI script that will give the caller status of a P.O.  When I run the script directly (by hand) it executes.  I know this because it leaves data in TEST.txt.  However, when I try to execute it via extensions.conf the CLI says it executes returning 0, but it does not dump data into TEST.txt.  Can anyone help me determine why?

extensions.conf  (snippet)

exten => 830,1,Read(Contno,enterpono,6,s)
exten => 830,2,Wait(1.2)
exten => 830,3,SatDigits(${Contno:0:6})
exten => 830,4,AGI(AP_info.agi|${Contno})


PO_info.agi

#!/usr/bin/perl

use Asterisk::AGI->new();

my ($contno) = $ARGV[0];

open (TEST, ">>/home/richard/TEST.txt") or die "Can't open"
print TEST "CONTNO " . $contno . "\n";
close (TEST);

use DBI;
my $dbh = DBI->connect("DBI:mysql:database=accounting;192.168.0.1",$user,$pass);

my $q = "SELECT amount, INV_RCVD, CHK_CUT, CHK_NO
              FROM payable p
              WHERE contno = ?";
my $sth = $dbh->prepare($q);
$sth->execute($contno);
my ($amount, $rcvd, $cut, $cno) = $sth->fetchrow_array;

if ($cno > 1) {
    $agi->exec('SayDigits', $amount);
    return $amount, $rcvd, $cut, $cno;
} elsif ($rcvd > 1) {
    $agi->exec('SayDigits', $amount);
    return $amount, $rcvd;
}

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

_______________________________________________
--Bandwidth and Colocation provided by Easynews.com --

Asterisk-Users mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/asterisk-users

Reply via email to