Topic: Get MySQL login and password [Comments: 2]
Fri, 03/06/2009 - 09:38 | Get MySQL login and password
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);





Tue, 02/09/2010 - 08:31 | Thanks for sharing! I've
Thanks for sharing! I've looked for something like this to get my course work finished in time!
Tue, 02/09/2010 - 16:36 | Is this fucking guy for real?
Is this fucking guy for real?