[asterisk-users] agi macro problem

Danny Nicholas danny at debsinc.com
Fri Jul 30 08:20:37 CDT 2010


In theory this snippet will do the trick

Save as updatech.pl

#!/usr/local/bin/perl -w

$ENV{PATH} = '/usr/sbin:/:/usr/bin:/usr/local/apache/bin'; # reasonable path

$ENV{ENV} = "/etc/bash.bachrc";

use strict;

use warnings;

use File::Find;

use DBI;

use Date::Calc qw(:all);

use Asterisk::AGI;

 

$|=1;

my $agi = Asterisk::AGI->new();

my %input = $agi->ReadParse();

 

my ($chanval) = @ARGV;

my $agi_channel = $input{'agi-channel'};

 

## db vars

my $data_source = "dbi:Pg:dbname=Asterisk";

my $username = "root";

my $auth = "xxx";

#

##---------- connect to the db --------------

##establish the DBI connection with transaction processing

my $dbh = DBI->connect($data_source, $username, $auth, {

   AutoCommit => 0,

   RaiseError => 1,

   } ) or die "Can't connect to database: ", $DBI::errstr, "\n";

 

 

# read the password file to get account type

my $upd_sh = $dbh->prepare( "UPDATE call_log SET local='CHANNEL' WHERE
id='$chanval' AND channel='$agi_channel'");

$upd_sh->execute();

$dbh->commit();

 

$dbh->rollback();

exit;

 

and change line 2 of the macro to exten => s,2,AGI(updatech.pl,$ARG1)

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20100730/384f0f8f/attachment.htm 


More information about the asterisk-users mailing list