Decent, but you need to watch your quotes....notice the single quote in
the chown command compared to the one in the chgrp command....
HTH
--
"Anderson, Bill" wrote:
>
> I found a bug in what I posted already. When the script copies the sorted
> list file over the original, the file owner and group are set to the user
> and group the script ran under, not majordomo. I had to add these lines to
> the end of the script:
>
> `chown majordomo *`;
> 'chgrp majordomo *`
>
> -----Original Message-----
> From: majordomo-users-owner@GreatCircle.COM
> [mailto:majordomo-users-owner@GreatCircle.COM]On Behalf Of Anderson,
> Bill
> Sent: Thursday, June 21, 2001 9:37 AM
> To: 'Majordomo Users'
> Subject: Sorting addresses by domain
>
> 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
--
Michael B. Weiner, Linux+, Linux+ SME
Systems Administrator/Partner
The UserFriendly Network (UFN)
--
Linux Registered User #94900 Have you been counted?
http://counter.li.org
PGP: 30 1D CC BA 30 30 63 35 CD 58 E0 89 A9 17 CC C0 8C 55 F7 72
......... Escape the 'Gates' of Hell
`:::' ....... ......
::: * `::. ::'
::: .:: .:.::. .:: .:: `::. :'
::: :: :: :: :: :: :::.
::: .::. .:: ::. `::::. .:' ::.
...:::.....................::' .::::..
--
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature
References:
|
|