[Asterisk-Users] AGI Module
Robert Jackson
RobertJ at promedicalinc.com
Sun Apr 18 20:40:14 MST 2004
Hey all,
I'm sorry to bother you with something so trivial, but I seem to
be having an issue with the Asterisk::AGI module. I am a relative
newbie with Perl so it could be a stupid syntax mistake that I missed.
It seems when I try to execute either the stream_file or the get_data
subs nothing is actually done. It doesn't seem to stream the files, but
on the console it says it played the file. If you need more information
please let me know and I will get it to you ASAP. Here are my source
and exentsions.conf:
Extensions.conf
---------------
; Test agi extension
exten => 3102,1,Answer
exten => 3102,2,AGI,agi-SQLTest.agi
exten => 3102,3,Hangup
Agi-SQLTest.agi
---------------
#!/usr/bin/perl
use Asterisk::AGI;
use DBI;
$AGI = new Asterisk::AGI;
# Read * input info.
my %input = $AGI->ReadParse();
# Set SQL server info.
$uid = 'asterisk';
$pwd = 'pbx';
$srv = 'SMARTTCom';
# Print variables for debugging.
$AGI->verbose("AGI Environment Dump:\n",3);
foreach $i (sort keys %input) {
$AGI->verbose(" -- $i = $input{$i}\n",3);
}
# Connect to server using freetds
$AGI->verbose("Connecting to server: $srv",3);
my $dbh = DBI->connect("dbi:Sybase:server=$srv", $uid, $pwd, {PrintError
=> 0});
die "Unable for connect to server $DBI::errstr"
unless $dbh;
$AGI->verbose('Getting account number.',2);
# Test stream_file. This is for debugging only.
# once fixed remove.
$AGI->stream_file('invalid','12345');
# Trying to get the caller's account number. This is not working
either.
$accountNumber = $AGI->get_data('agi-enteraccountnumber','15000','5');
# If accountNumber is blank then just queue the caller into the
# 'unverified' queue.
if ('foo' . $accountNumber eq 'foo') {
$AGI->exec('Queue', 'unverified-patientq');
$AGI->verbose('No account number entered', 1);
exit(0);
}
# Run query to get verification data from server.
$AGI->verbose('Executing queury',3);
my $sth = $dbh->prepare("select SSN, [Birth Date], Zip, [Home Phone]
from SEARCHBASE where [Demo#] = $accountNumber");
$sth->execute();
if ($sth->rows == 1) {
@data = $sth->fetchrow_array();
my $ssn = $data[0];
my $dob = $data[1];
my $dob = $data[1];
my $zip = $data[2];
my $homePhone = $data[3];
$AGI->verbose("Data returned: $ssn, $dob, $zip, $homePhone",3)
} else {
$AGI->verbose("Invalid account number: $accountNumber",1);
$AGI->exec('Queue', 'unverified-patientq');
exit(0);
}
$sth->finish;
$dbh->disconnect;
Exit;
Any help would be greatly appreciated.
Thanks,
Robert Jackson
More information about the asterisk-users
mailing list