Skip to Content.
Sympa Menu

en - Re: [sympa-users] Reading from list configuration files

Subject: The mailing list for listmasters using Sympa

List archive

Chronological Thread  
  • From: David Verdin <address@concealed>
  • To: Chris Pax <address@concealed>
  • Cc: address@concealed
  • Subject: Re: [sympa-users] Reading from list configuration files
  • Date: Fri, 13 Nov 2009 15:54:21 +0100

Hi chris,

The right library to use is "List.pm". It contains all the functions necessary to load and write a list config. Note that thi library uses other libraries, mentionned in the "use" clauses.

Here is an example of code that should do it (more or less, I took it from sympa.pl and may have forgotten something):

my $config_file = "full path to your sympa.conf file";
## Load configuration file. Ignoring database config for now: it avoids trying to load a database that could not exist yet.
unless (Conf::load($config_file,1)) {
&fatal_err("Configuration file $config_file has errors.");
}
## Apply defaults to %List::pinfo
&List::_apply_defaults();
## going to the Sympa install directory
if (!chdir($Conf{'home'})) {
fatal_err("Can't chdir to %s: %m", $Conf{'home'});
## Function never returns.
}
#Now opening the list and editing the config
my $list = new List ('listname');
$list->{'admin'}{'list_prameter_name'} = "new_value"; #note that if the parameter is a hash or an array, the value setting will be more coplex.
my $email = 'your_email_address';#that's the email of the person updating the config
$list->save_config($email);

In addition, I want to submit to your addition the sympa list families (https://www.sympa.org/manual/list-families). It provides a solution to have lists whose configuration can be updated by groups, according to constraints and data found in XML files.
It is worth a look if you want to modify a large number of list at once.

Cheers,

David

Chris Pax a écrit :
using perl,
i would like to read in a list configuration file, in to an array or object,
change or add a parameter,
and then write out the changes to the configuration file.

what do I include from your code?
and can you provide a example of using it?


thanks,


--
David Verdin
Comité réseau des universités




Archive powered by MHonArc 2.6.19+.

Top of Page