man, 04.10.2004 kl. 07.43 skrev Jonathan Angliss:

> > But the same 192 users have flat-file based user data and as soon as I
> > switch over, all their data info will have to be reentered. So, (since
> > they're all in LDAP-based users) I write a shell script (bash, Openldap
> > tools, awk, sed) to cat their present settings, and mail them that on
> > Sunday next, their SM data settings will be void and will have to be
> > re-entered, "here are their present settings".
> 
> [..]
> 
> > Anybody ever had to do this before and has a prescribed solution?
> 
> I remember somebody had wrote a perl script a while back to go through
> the prefs files, and convert them over. You might be able to search
> gmane to find the details. If you cannot track them down, let me know,
> and I'll see if I can knock together a quick script to handle it.

Hi Jonathan,

Daniel Drucker gave details of the script*s location. I downloaded it,
but my Perl 5.8 barfs and gives all sorts of compile errors and my Perl
skill ia seriously challenged.

I've attached the whole page I downloaded (obviously I deleted the
non-relevant bits first :) If you could tidy it up and make it work, I'd
be very grateful.

Best,

--Tonni

-- 
�Livet er ein gamp�, sa �yken.
I can confirm this.

mail: [EMAIL PROTECTED]
http://www.billy.demon.nl

They love us, don't they, They feed us, won't they
OSTG | ThinkGeek - Slashdot - ITMJ - IT Product Guide - Linux.com - NewsForge - freshmeat - Newsletters - TechJobs - Broadband *my sf.net * *software map * *donate to sf.net * *about sf.net * *Login via SSL New User via SSL * * Search* powered by *YAHOO! search* * SF.net Subscription* * · *Subscribe Now * · *Manage Subscription * · *Advanced Search * · *Direct Download * · *Priority Tech Support * · *Project Monitoring * SF.net Resources* * · **Site Docs* * · *Site Status (10/02) * · *SF.net Supporters * · *Compile Farm * · *Foundries * · *Project Help Wanted * · *New Releases * · **Get Support* * Site Sponsors* *Most Active* *1* Gaim *2* phpMyAdmin *3* Azureus - BitTorrent Client *4* eGroupWare: Enterprise Collaboration *5* WinMerge *6* Compiere ERP + CRM Business Solution *7* openCRX - Limitless Relationship Mgmt *8* WebCalendar *9* FileZilla *10* Gallery More Activity >> *Top Downloads* *1* eMule *2* BitTorrent *3* Azureus - BitTorrent Client *4* Shareaza *5* DC++ *6* eMule Plus *7* CDex *8* VirtualDub *9* ABC [Yet Another Bittorrent Client] *10* VisualBoyAdvance More Statistics >> * SF.net Services* * · *Tech Jobs * · *Online Books * · *Comparison Shop * · *Partner Product Offers * · *Get Broadband * · *IT Research Library * · *IT Product Guide * Sponsored Content* * Project: SquirrelMail: Mailing Lists * ------------------------------------------------------------------------ Summary | Admin | Home Page | Tracker | Bugs | Patches | RFE | Lists | Tasks | Docs | News | CVS | Files | ------------------------------------------------------------------------ Email Archive: squirrelmail-users (read-only) Search From: Michael Blandford <[EMAIL PROTECTED]> flat2sql.pl - convert abook, prefs, and sig files into sql 2002-03-04 20:58 Here is a perl script that Tal and I put together to convert our existing flat config files into sql. It doesnt create the table, it just generates output to insert the data. It can do partial data ( prefs or abook, or sig ) or all data. It can also take a list of users, or by default, do all users. Would something like this be beneficial to add to the distro? Michael & Tal #!/usr/bin/perl # flat2sql.pl v1.0 # # Copyright (c) 2002, Michael Blandford and Tal Yardeni ##### Conf Section ##### $data_dir = "/var/www/html/mail/data"; $db = "squirrelmail"; $abook_table = "address"; $pref_table = "userprefs"; ##### ##### ##### use Getopt::Long; &GetOptions( \%opts, qw( abook data_dir:s delete h help pref sig user:s ) ); &Usage if ( defined $opts{h} or defined $opts{help} ); unless ( defined $opts{abook} or defined $opts{pref} or defined $opts{sig}) { $opts{abook}=TRUE; $opts{pref}=TRUE; $opts{sig}=TRUE; } # Override the data directory if passed as an argument $data_dir = $opts{data_dir} if ( defined $opts{data_dir} ); # Are we looking for specific users or all users? # There has to be a better way to do this - Below @user_list = split ( /,/, $opts{user} ) if defined $opts{user}; # Here we go # If no arguments are passed, and we cant open the dir, we should # get a usage. opendir(DIR, $data_dir) or die "DIRECTORY READ ERROR: Could not open $data_dir!!\n"; while ( $filename = readdir DIR ) { next if ( $filename eq "." or $filename eq ".." ); $filename =~ /(.*)\.(.*)/; $username = $1; # Deal with the people # There has to be a better way to do this - Above next if ( defined $opts{user} and grep(!/$username/,@user_list)); # Deal with the extension files $ext = $2; next unless $ext; &abook if ( $ext eq "abook" and defined $opts{abook} ); &pref if ( $ext eq "pref" and defined $opts{pref} ); &sig if ( $ext =~ /si([g\d])$/ and defined $opts{sig}); } closedir ( DIR ); # All done. Below are functions # Process a user address file sub abook { print "DELETE FROM $db.$abook_table WHERE owner = "$username;\n" if ( defined $opts{delete} ); concat(ABOOK, ">$data_dir/$filename") or die "FILE READ ERROR: Could not open $filename!!\n"; while (my $line = ) { chomp $line; my ( $nickname,$firstname,$lastname,$email,$label ) = split(/\|/, $line); print "INSERT INTO $db.$abook_table " . "(owner,nickname,firstname,lastname,email,label) " . "VALUES ("$username","$nickname","$firstname","$lastname"," . ""$email","$label");\n"; } close(ABOOK); } # Process a user prefernce file sub pref { print "DELETE FROM $db.$pref_table " . "WHERE user = "$username" and prefkey not like "___sig\%___";\n" if ( defined $opts{delete} ); concat(PREFS, "<$data_dir/$filename") or die "FILE READ ERROR: Could not open $filename!!\n"; while (my $line = ) { chomp $line; my ( $prefkey, $prefval ) = split(/=/, $line); print "INSERT INTO $db.$pref_table " . "(user,prefkey,prefval) " . "VALUES ("$username","$prefkey","$prefval");\n"; } close(PREFS); } # Process a user sig file sub sig { $del_ext = $1; $del_ext = "nature" if ( $del_ext eq "g" ); print "DELETE FROM $db.$pref_table " . "WHERE user = "$username" and prefkey like "___sig" . $del_ext . "___";\n" if ( defined $opts{delete} ); concat(SIG, "<$data_dir/$filename") or die "FILE READ ERROR: Could not open $filename!!\n"; my @lines = ; close(SIG); $filename =~ /.*\.si([g,\d]$)/; $prefkey = "___sig"; if ( $1 eq "g" ) { $prefkey .= "nature___"; } else { $prefkey .= "$1___"; } print "INSERT INTO $db.$sig_table (user,prefkey,prefval) " . "VALUES ("$username","$prefkey","".join("",@lines)."");\n"; } # Print out the usage screen sub Usage { $0 =~ /.*\/(.*)/; $prog = $1; print <] [--user= ) already in the database. This is useful to reimport users. It respects --abook, --pref, and --sig. If --user is not specified, it will try to do all users. EOL exit 1; } Thread View *Thread* *Author* *Date* flat2sql.pl - convert abook, prefs, and sig files into sql Michael Blandford <[EMAIL PROTECTED]> 2002-03-04 20:58 Re: flat2sql.pl - convert abook, prefs, and sig files into sql Rene Madsen <[EMAIL PROTECTED]> 2002-03-05 02:10 Powered by SourceForge® collaborative development environment from VA Software © Copyright 2004 - OSTG Open Source Technology Group, All Rights Reserved About SourceForge.net ? About OSTG ? Privacy Statement ? Terms of Use ? Advertise ? Get Support

Reply via email to