Olivier
2009-May-22 07:23 UTC
[asterisk-users] Parsing Asterisk's .conf files from Perl, Java or PHP file
Hi, To a large extend, Asterisk's /etc/asterisk/*.conf configuration files conform to a format such as: [section1] key1=value1 key2=value2 [section2] key1=value1 key2=value2 ... To increase coherence when running custom-made application in Perl, Java, PHP, ...) and Asterisk on the same platform, I'm wondering if could extend a bit Asterisk's config files instead of duplicating data in an independant config file. For instance, an app that uses Manager interface needs to be configured with : - the Asterisk manager interface IP address, - a username and secret. The later 2 parameters are included /etc/asterisk/manager.conf but the first one is not. So instead of writing an independant myapp.conf holding all 3 parameters, should I only add the first parameter to existing manager.conf file ? Doing this, I would have to make sure that when Asterisk is parsing its config file, it doesn't stop when it reads unkown supplementary parameters (those added for custom app). It seems to be the case now with 1.6.1 : a NOTICE warning is sent but it doesn't really hurt. [May 22 09:15:32] NOTICE[15917]: manager.c:3903 __init_manager: Invalid keyword <foo> = <bar> in manager.conf [general] Maybe, adding a keyword that would tell Asterisk to skip reading this config file line would be a plus (avoiding warnings and collision with new keywords). What do you think ? Then, my next question, is there widely available librairies to parse Asterisk's config files-like files ? Regards -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090522/f3a43429/attachment.htm
Matt Watson
2009-May-22 12:44 UTC
[asterisk-users] Parsing Asterisk's .conf files from Perl, Java or PHP file
There already is a special character to tell asterisk not to parse a line... its: ";" that is why the default configuration is completely filled with lines that start with ; its considered a comment character to asterisk and will make it ignore the line... you'd just want to add some extra characters to your program probably... something that would denote "this is a config line for script A" so if you make your lines something like ;A: then you could have another character for script B that would have lines in the same file like: ;B: or w/e... its up to you to determine what characters you'd want to use beyond the ; to denote config lines for your other programs. -- Matt On Fri, May 22, 2009 at 3:23 AM, Olivier <oza-4h07 at myamail.com> wrote:> Hi, > > To a large extend, Asterisk's /etc/asterisk/*.conf configuration files > conform to a format such as: > > [section1] > key1=value1 > key2=value2 > > [section2] > key1=value1 > key2=value2 > ... > > To increase coherence when running custom-made application in Perl, Java, > PHP, ...) and Asterisk on the same platform, I'm wondering if could extend a > bit Asterisk's config files instead of duplicating data in an independant > config file. > > For instance, an app that uses Manager interface needs to be configured > with : > - the Asterisk manager interface IP address, > - a username and secret. > > The later 2 parameters are included /etc/asterisk/manager.conf but the > first one is not. > So instead of writing an independant myapp.conf holding all 3 parameters, > should I only add the first parameter to existing manager.conf file ? > > Doing this, I would have to make sure that when Asterisk is parsing its > config file, it doesn't stop when it reads unkown supplementary parameters > (those added for custom app). > It seems to be the case now with 1.6.1 : a NOTICE warning is sent but it > doesn't really hurt. > [May 22 09:15:32] NOTICE[15917]: manager.c:3903 __init_manager: Invalid > keyword <foo> = <bar> in manager.conf [general] > > Maybe, adding a keyword that would tell Asterisk to skip reading this > config file line would be a plus (avoiding warnings and collision with new > keywords). > What do you think ? > > Then, my next question, is there widely available librairies to parse > Asterisk's config files-like files ? > > Regards > > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20090522/c86f641c/attachment.htm
Roderick A. Anderson
2009-May-22 13:36 UTC
[asterisk-users] Parsing Asterisk's .conf files from Perl, Java or PHP file
Olivier wrote:> Hi, > > To a large extend, Asterisk's /etc/asterisk/*.conf configuration files > conform to a format such as: > > [section1] > key1=value1 > key2=value2 > > [section2] > key1=value1 > key2=value2 > ... > > To increase coherence when running custom-made application in Perl, > Java, PHP, ...) and Asterisk on the same platform, I'm wondering if > could extend a bit Asterisk's config files instead of duplicating data > in an independant config file. > > For instance, an app that uses Manager interface needs to be configured > with : > - the Asterisk manager interface IP address, > - a username and secret. > > The later 2 parameters are included /etc/asterisk/manager.conf but the > first one is not. > So instead of writing an independant myapp.conf holding all 3 > parameters, should I only add the first parameter to existing > manager.conf file ? > > Doing this, I would have to make sure that when Asterisk is parsing its > config file, it doesn't stop when it reads unkown supplementary > parameters (those added for custom app). > It seems to be the case now with 1.6.1 : a NOTICE warning is sent but it > doesn't really hurt. > [May 22 09:15:32] NOTICE[15917]: manager.c:3903 __init_manager: Invalid > keyword <foo> = <bar> in manager.conf [general] > > Maybe, adding a keyword that would tell Asterisk to skip reading this > config file line would be a plus (avoiding warnings and collision with > new keywords). > What do you think ? > > Then, my next question, is there widely available librairies to parse > Asterisk's config files-like files ?Not specific to Asterisk but there is Config::Std which, in Damian's blurb for the module, is simple and limited. Still it could work or be beat into submission. :-) \\||/ Rod --> > Regards > > > ------------------------------------------------------------------------ > > _______________________________________________ > -- Bandwidth and Colocation Provided by http://www.api-digital.com -- > > asterisk-users mailing list > To UNSUBSCRIBE or update options visit: > http://lists.digium.com/mailman/listinfo/asterisk-users
Tzafrir Cohen
2009-May-23 00:39 UTC
[asterisk-users] Parsing Asterisk's .conf files from Perl, Java or PHP file
On Fri, May 22, 2009 at 09:23:32AM +0200, Olivier wrote:> Hi, > > To a large extend, Asterisk's /etc/asterisk/*.conf configuration files > conform to a format such as: > > [section1] > key1=value1 > key2=value2 > > [section2] > key1=value1 > key2=value2 > ... > > To increase coherence when running custom-made application in Perl, Java, > PHP, ...) and Asterisk on the same platform, I'm wondering if could extend a > bit Asterisk's config files instead of duplicating data in an independant > config file.Asterisk::config seems to work nicely. It does not support all the features but the basics you're interested in are supported. http://search.cpan.org/~hoowa/Asterisk-config-0.96/ (Or just search CPAN for "asterisk" / "asterisk::config" ) -- Tzafrir Cohen icq#16849755 jabber:tzafrir.cohen at xorcom.com +972-50-7952406 mailto:tzafrir.cohen at xorcom.com http://www.xorcom.com iax:guest at local.xorcom.com/tzafrir
Maybe Matching Threads
- Read Windows-like .INI files into R data structure?
- [PATCH: host-browser replacement 0/3] replacement of host-browser on ovirt-server
- Re: RFC: arbitrary parameters for add_drive
- Feature request: "database show" from manager API
- [PATCH: server 0/3] Add host-register.rb (replaces host-browser.rb in part)