list-config_modif_topics.pl

lister les listes à modifier dans listemodif

#!/usr/bin/perl -w
#
# list-config_modif_topics.pl
#
# Catherine.Balleydier@grenoble-inp.fr
#
# maj : 02/03/09
#
########################################################################
# 
#   modifier le topic d'une liste
#
########################################################################
#
use strict;
use warnings;
use File::Copy;
 
my $REP="/home/sympa/list_data/listes.grenoble-inp.fr/";
my $nvtopics = "dsi/06technique" ;
 
my $listfich = "/usr/local/SCRIPTS/sympa/listemodif ";
my $fichier ;
my $nvfichier ;
my @CONFIG ;
my $entree ;
my $LIGNE;
 
#
#  date
#
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
my $marque = (1900+$year)."_".($mon+1)."_"."$mday"."_"."$hour"."_"."$min" ;
print "$marque\n";
 
#
#  ouvrir le fichier contenant les listes a modifier
#
open (FICH1,"$listfich") ||die "probleme fichier";
my @LISTES = <FICH1> ;
close (FICH1);
 
# traiter pour chaque liste le fichier config
#
foreach $entree (@LISTES)
#$entree = "spip.responsable" ;
{
   chomp $entree ;
  $fichier = "$REP"."$entree"."/config" ; 
  copy ("$fichier", "$fichier"."."."$marque") ;
  open (FICH,"$fichier") ||die "probleme fichier";
  @CONFIG = <FICH> ;
  close (FICH) ;
 
  $nvfichier  = "$REP"."$entree"."/nvconfig" ;
  open (NVFICH,">$nvfichier") ||die "probleme nvfichier";
 
  foreach $LIGNE (@CONFIG)
  {
    chomp $LIGNE ;
    if ( $LIGNE =~ /topics/ )
    {
      $LIGNE = "topics "."$nvtopics"."\n" ;
    }
    print NVFICH "$LIGNE\n" ;
  }
 
  close (NVFICH) ;
  rename ("$nvfichier","$fichier") ;
}