Subject: The mailing list for listmasters using Sympa
List archive
Re: [sympa-users] Script to export subscribers to text/excel, etc.?
- From: Liam Kirsher <address@concealed>
- To: address@concealed
- Cc: Michelle Murrain <address@concealed>
- Subject: Re: [sympa-users] Script to export subscribers to text/excel, etc.?
- Date: Tue, 15 Jun 2004 12:25:27 -0700
Michelle,
Maybe this will help as a starting point... I send my subscribers a weekly backup for our mutual peace of mind. In this case I'm also saving the user's subscriber options, but you can just change the SQL statement to whatever you want.
Liam
#!/usr/bin/perl
##
## sympa_backup
##
## backup the sympa mailing lists
## 1. extract from mysql database
## 2. compress using gzip
## 3. send as MIME attachment
##
## Liam K. 5/21/04
##
use MIME::Lite;
# note: these are the list names, which must be unique across all
# domains hosted on this site, together with email address of recip.
%list_names = (
name_of_list => 'address@concealed',
);
# create a date string
($sec, $min, $hour, $mday, $mon, $year) = localtime(time);
$date = sprintf("%4d%02d%02d_", $year+1900, $mon+1, $mday);
$formatted_date = sprintf("%d/%d/%d", $mon+1, $mday, $year+1900);
foreach $list (sort keys %list_names) {
#print "processing $list...\n";
$TXTFILE="/tmp/$date$list.txt";
$ATTFILE="$date$list.txt.gz";
$SUBJECT="List backup on $formatted_date for $list";
$MAILTO=$list_names{$list};
$select = "SELECT * INTO OUTFILE \'$TXTFILE\' ";
$select .= "FIELDS TERMINATED BY \',\' OPTIONALLY ENCLOSED BY \'\\\"\' ";
$select .= "LINES TERMINATED BY \'\\n\' ";
$select .= "FROM subscriber_table WHERE list_subscriber = \'$list\'";
#print $select, "\n";
# extract list addresses from database
#print "extracting addresses from database...\n";
system ( "/usr/bin/mysql -usympa -p<sympa password here> -e \"$select\" sympa") == 0 or die "failed to extract addresses!";
# compress list, overwriting if necessary
#print "compressing list...\n";
system ( "/bin/gzip -f $TXTFILE") == 0 or die "failed to gzip file!";
# Create a new multipart message:
#print "creating MIME\n";
$msg = new MIME::Lite
From => "$ENV{LOGNAME}",
To => "$MAILTO",
Subject => "$SUBJECT",
Type => 'multipart/mixed';
# Add parts (each "attach" has same arguments as "new"):
#attach $msg
#Type => 'text/plain',
#Data => "Here's the $list list, as of $formatted_date.";
attach $msg
Type => 'application/octet-stream',
Encoding => 'base64',
Path => "/tmp/$ATTFILE",
Filename => "$ATTFILE";
# Output the message to sendmail
#print "sending via SENDMAIL\n";
open (SENDMAIL, "| /usr/lib/sendmail -t -oi");
$msg->print(\*SENDMAIL);
close(SENDMAIL);
# cleanup
unlink "/tmp/$ATTFILE";
}
At 01:16 PM 6/15/2004 -0400, you wrote:
Hi there,
In looking around, I couldn't find it, but I imagine someone on this list has written a simple CLI script to extract subscribers from sympa lists?
If so, could I get a copy? If not, I have to write one, so I'll send it in when I'm done.
Thanks!!
--
.Michelle
--------------------------
Michelle Murrain
mmurrain at dbdes dot com
413-222-6350 ph
617-889-0929 ph
952-674-7253 fax <--- new
Page: address@concealed
AIM:pearlbear0 ICQ:129250575
Y!: michelle_murrain Jabber: address@concealed
"Work like you don't need the money. Love like you've never been hurt. Dance like nobody's watching." - Satchel Paige
Liam Kirsher <liamk/AT/numenet/DOT/com>
415-488-4370
415-509-6822 (cell)
PGP:
http://liam.numenet.com/pgp/
-
Script to export subscribers to text/excel, etc.?,
Michelle Murrain, 06/15/2004
-
Re: [sympa-users] Script to export subscribers to text/excel, etc.?,
Liam Kirsher, 06/15/2004
-
Re: [sympa-users] Script to export subscribers to text/excel, etc.?,
Serge Aumont, 06/15/2004
- Re: [sympa-users] Script to export subscribers to text/excel, etc.?, Ryan Williams, 06/15/2004
-
Re: [sympa-users] Script to export subscribers to text/excel, etc.?,
Serge Aumont, 06/15/2004
-
Re: [sympa-users] Script to export subscribers to text/excel, etc.?,
Liam Kirsher, 06/15/2004
Archive powered by MHonArc 2.6.19+.