[Asterisk-Users] AGI MySql

Akpome Akpoguma akpome_a at hotmail.com
Mon May 29 00:58:40 MST 2006


The following is my AGI script done in perl

#!/usr/bin/perl

use strict;
use DBI;

$|=1;

my %AGI;

while(<STDIN>) {

	chop;
	last unless length($_);
	if (/^agi_(\w+)\:\s+(.*)$/) {
		$AGI{$1} = $2;
		}
	}

my $ext = $AGI{extension};

if (!($ext)) { $ext = 10; }

my $dbh = DBI->connect('dbi:mysql:voiceDb', 'test', 'test', {PrintError=>0, 
RaiseError=>1});
my $sql = "select filename from contentTable where ext='$ext'" or die 
$dbh->errstr;
my $filename = $dbh->selectrow_array($sql);
$dbh->disconnect;

$filename =~ s/\.wav//i;
print "STREAM FILE $filename \"\"\n";

exit;

The return value of $filename from the database is supposed to be 
/var/sounds/scoobie.wav.

There are 2 Problems

1. When I execute this script manually it works well but when I call this 
script from dialplan I get no return value.
2. I did print "STREAM FILE /var/sounds/scoobie \"\"\n" and the phone was as 
silent even though I see no error on the console.

Am clueless as to how to fix this. I need someone's 
assistance.......resposes would be appreciated.

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE! 
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/




More information about the asterisk-users mailing list