At 10:24 AM 4/21/2004, you wrote:
It's possible to write a perl script to parse an email and run add_members... then set up an account on the server that is allowed to run the script under sudo with no password... then have his .forward file contain the line "| sudo scriptname". Honestly it sounds like a hackish way of doing it, but it could work.

Here's a sample script that I've whipped up quickly. It's probably full of bugs and it's untested, but here it is. I've added the capability to add regular users and digest users, as well as the ability to remove users from a list.


Assuming the moderator wanted to add [EMAIL PROTECTED] as a digest, [EMAIL PROTECTED] as a regular, and remove [EMAIL PROTECTED], the body of the email would look like this:

digest [EMAIL PROTECTED]
regular [EMAIL PROTECTED]
remove [EMAIL PROTECTED]

----- begin script -----
#!/bin/perl

$listname="listnamehere";

$addscript="/usr/local/mailman/bin/add_members";
$addargs="-w n -a n";
$addregtempfile="/tmp/regulartemp";
$adddigtempfile="/tmp/digesttemp";

$remscript="/usr/local/mailman/bin/remove_members";
$remargs="-nN";

until(<STDIN> =~ /^$/) {
        # Do nothing... this loop throws away headers
}

# Remove one more line... the blank line between
# mail headers and body
$nothing = <STDIN>;

# add_members requires that email addresses be put in a file:
# one for regular subscriptions, one for digest subscriptions:
open(REGULAR, ">$addregtemp") || die "can't create tempfile regulartemp\n";
open(DIGEST, ">$adddigtemp") || die "can't create tempfile digesttemp\n";

# remove_members allows putting email addresses on the command line,
# so we can put all those email addresses in an array
@removals=();

while(<STDIN>) {
        if($_ =~ /^digest /) {
                s/^digest //;
                print DIGEST $_;
        } elsif ($_ =~ /^regular /) {
                s/^regular //;
                print REGULAR $_;
        } elsif ($_ =~ /^remove /) {
                s/^remove //;
                chomp;
                push(@removals);
        } else {
                print STDERR "invalid command";
        }
}

close DIGEST;
close REGULAR;

# run the scripts using the info provided
system "$addscript $addargs -r $addregtemp -d $adddigtemp $listname";
system "$remscript $remargs $listname @removals";

# remove temp files
unlink $adddigtemp;
unlink $addregtemp;
----- end script -----

/tim
--
Tim Faircloth, System Administrator
GSW OIIT
Office: (229) 931-5076  Beeper: (229) 928-1458


------------------------------------------------------ Mailman-Users mailing list [EMAIL PROTECTED] http://mail.python.org/mailman/listinfo/mailman-users Mailman FAQ: http://www.python.org/cgi-bin/faqw-mm.py Searchable Archives: http://www.mail-archive.com/mailman-users%40python.org/

Reply via email to