Great Circle Associates Majordomo-Users
(June 2001)
 

Indexed By Date: [Previous] [Next] Indexed By Thread: [Previous] [Next]

Subject: Re: Sorting addresses by domain
From: jacks @ sage-american . com
Date: Thu, 21 Jun 2001 14:59:39 -0500
To: "Anderson, Bill" <wander01 @ mail . state . mo . us>, "'Majordomo Users'" <Majordomo-users @ GreatCircle . COM>
In-reply-to: <D2421549D378D3119D4E000629840F07042CE233@ECOEXCHG>

Bill: Thanks for the script. I took a little different approach that is
used for each separate lists if more than one. I use a korn shell cron job
as follows that runs as frequently as I want for each list depending on how
active and/or large it is:
*******************************************************
KORN SHELL - sortfoolist.ksh
#!/bin/ksh

# Sort the foolist
# The following is a "dated" extra backup for safety and is optional
cp ~/usr/local/majordomo/lists/foolist ~/bak/foolist`date +".%m.%d.%H.%M"`
# before sort rename the list to a backup sort work file
mv ~/usr/local/majordomo/lists/foolist ~/usr/local/majordomo/lists/foolist.bak
# now sort
cat ~/usr/local/majordomo/lists/foolist.bak | tr A-Z a-z | sort -t@ -k2 >
~/usr/local/majordomo/lists/foolist
# get rid of the "bak" file
rm -f ~/usr/local/majordomo/lists/foolist.bak
# mail myself a notice that the job is done
mail -s "foolist has been sorted" jacks < ~/listsort
*******************************************************
That's all there is to it.....

At 09:36 AM 6.21.2001 -0500, Anderson, Bill wrote:
>The recent discussions on how to improve majordomo/sendmail performance by
>sorting the list files by domain prompted me to try to do this for my own
>lists. Finding no script to do this already written, I put together the
>following perl script to do the sorting. The directory the list files are in
>is defined in the chdir function in the script. The script assumes the list
>files are the only files in the directory _without_ a period in the name.
>
>#! /usr/bin/perl
>
>chdir "/var/lib/majordomo/lists/testdir";
>@listnames = `ls`;
>@lists = grep (!/\./, @listnames);
>unlink 'lists.out';
>
>for my $list (@lists)
>   {
>      chomp $list;
>      open LISTFILE, $list;
>      print $list."\n";
>      @fileaddresses = ();
>
>      while (<LISTFILE>)
>      {
>         chomp;
>         ($account, $host) = split (/\@/,  $_); 
>         push @fileaddresses, lc($host)."@".lc($account)."\n";
>      }
>
>      @sortedaddresses = sort @fileaddresses;
>      open OUTFILE, ">>sortedlist.out";
>
>      for my $sortedaddress (@sortedaddresses)
>      {
>         chomp $sortedaddress;
>         ($sortedhost, $sorteddest) = split (/\@/, $sortedaddress);
>         print OUTFILE $sorteddest."@".$sortedhost."\n";
>      }
>      close OUTFILE;
>
>      `mv sortedlist.out $list`;
>      unlink "sortedlist.out"; 
>   }
>
>All comments/suggested improvements are welcome.
>
>Bill Anderson
>MIS Network Administrator
>MO Dept of Economic Development
>
>
>
>

Best regards,
Jack L. Stone,
Administrator

Sage American
http://www.sage-american.com
jacks@sage-american.com



References:
Indexed By Date Previous: Re: Message duplication problem
From: Kirk Ismay <captain@netidea.com>
Next: RE: Sorting addresses by domain
From: "Anderson, Bill" <wander01@mail.state.mo.us>
Indexed By Thread Previous: Sorting addresses by domain
From: "Anderson, Bill" <wander01@mail.state.mo.us>
Next: Re: Sorting addresses by domain
From: Tom Lettington <tom@tfl.net>

Google
 
Search Internet Search www.greatcircle.com