4 posts / 0 new
Last post
cbbs70a
cbbs70a's picture
Joined: 2008/04/10
Points: 0

This is a little script I wrote that will retrieve the MySQL login and password to be used in the dialplan. This way, that info does not have to be hard coded. Example included.

#!/usr/bin/perl

#
# get_mysql_params.agi - Get the MySQL login and passwd
# so they do not have to be hardcoded in the dialplan. Reads
# /etc/asterisk/res_mysql.conf. Needs PERL module Config::Std
# and Asterisk::AGI. Dialplan example:
# exten => s,1,AGI(get_mysql_params.agi)
# exten => s,2,MYSQL(Connect connid ${DBHOST} ${DBUSER} ${DBPASS} ${DBNAME})
# By FSD. fsd@voipbusiness.us
#

use strict;
use Config::Std;
use Config::Std { def_sep => '=' };
use Asterisk::AGI;

our $AGI = new Asterisk::AGI;

my $configfile = "/etc/asterisk/res_mysql.conf";
read_config "$configfile" => my %config;
my $dbhost = $config{general}{'dbhost'};
my $dbname = $config{general}{'dbname'};
my $dbuser = $config{general}{'dbuser'};
my $dbpass = $config{general}{'dbpass'};
my $dbport = $config{general}{'dbport'};

$AGI->set_variable('DBHOST',$dbhost);
$AGI->set_variable('DBNAME',$dbname);
$AGI->set_variable('DBUSER',$dbuser);
$AGI->set_variable('DBPASS',$dbpass);
$AGI->set_variable('DBPORT',$dbport);

exit(0);

Donnie
Donnie's picture
Joined: 2010/02/09
Points: 0

Thanks for sharing! I've looked for something like this to get my course work finished in time!

cbbs70a
cbbs70a's picture
Joined: 2008/04/10
Points: 0

Is this fucking guy for real?

OliviaWild
OliviaWild's picture
Joined: 2011/06/03
Points: 0

Oh I think it's really one of the most stupid but popular problem!

English essays