Great Circle Associates Majordomo-Users
(January 1996)
 

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

Subject: Little scripts for adding/deleted
From: (John Sechrest) <sechrest @ peak . org>
Date: Mon, 15 Jan 1996 13:37:04 -0800
To: majordomo-users @ greatcircle . com


Hello,

	Over the last bit of creating and managing several mailing 
	lists, I found that I kept getting my hands in the
	adding and deleting process for lists.

	I liked the bounce command, but I did not want to have
	people added to a list. 
	
	And I also did not like having to add people by hand
	to lists and remember what system they were on.

	So, a minor amount of modification to bounce produced two
	scripts:

	mdadd and mdrm

	These add and delete people from lists.

	I hope that you find them useful:

#!/usr/local/bin/perl
# mdadd - Major Domo Add 
#
# Based around "bounce", this script will add a user to a list
# 
# Usage: mdadd [-f <config-file>] [-d] <list> <user>\nStopped
#
# Assumes that the "approve" password for each list is stored in a file
# called ".majordomo" in the user's home directory, in the following format:
# 
# 	List		Password	Majordomo-Address
# 
# When you add someone to a list, it looks up that lists's password
# and Majordomo-Address (the address of the Majordomo server serving that
# list) in the .majordomo file
# 
# Here's an example of what a .majordomo file should look like:
# 
# 	this-list	passwd1		Majordomo@This.COM
# 	other-list	passwd2		Majordomo@Other.GOV

# A command of "mdadd this-list user@fubar.com" will mail the
# following message to Majordomo@This.COM:
# 
# 	approve passwd1 subscribe this-list user@fubar.com

# Original Author:
# Brent Chapman                                   Great Circle Associates
# Brent@GreatCircle.COM                           1057 West Dana Street
# +1 415 962 0841                                 Mountain View, CA  94041
#
# mdadd mucked with by John Sechrest
# 			sechrest@peak.org
# $Source: /sources/cvsrepos/majordomo/bounce,v $
# $Revision: 1.1.1.1 $
# $Date: 1993/08/31 16:05:00 $
# $Author: rouilj $
# $State: Exp $
#
# $Locker:  $
#

require "getopts.pl";

&Getopts("df:") ||
    die("USAGE: mdadd [-f <config-file>] [-d] <list> <user>\nStopped");

if (! defined($opt_f)) {
    $opt_f = <~/.majordomo>;
}

&read_config();

$list = shift(@ARGV);
$list =~ tr/A-Z/a-z/;
$list =~ s/@.*//;

$list_passwd = $passwd{$list};
if (! $list_passwd) {
    die("no password for list $list; stopping");
}

local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;

if (defined($opt_d)) {
    open(MSG, ">&STDOUT");
} else {
    open(MSG, "|/usr/lib/sendmail $majordomo{$list}") || 
	die("open(MSG, \"|/usr/lib/sendmail $majordomo{$list}\"): $!\nStopped");
}

print MSG <<EOF;
To: $majordomo{$list}

EOF

foreach (@ARGV) {
    printf MSG "approve %s subscribe %s %s\n", $list_passwd, $list, $_;
}
close(MSG);

exit 0;

sub read_config {
    open(CONF, $opt_f) || die("open(CONF, \"$opt_f\"): $!");
    while (<CONF>) {
	s/\n$//;
	s/#.*//;
	if (/^$/) { next; }
	split;
	$_[0] =~ tr/A-Z/a-z/;
	$_[2] =~ tr/A-Z/a-z/;
	$passwd{$_[0]} = $_[1];
	$passwd{"$_[0]@$_[2]"} = $_[1];
	$majordomo{$_[0]} = $_[2];
    }
    close(CONF);
}





------


mdrm 


#!/usr/local/bin/perl
# Instead of
# move problem addresses from <list> to "bounces"
# Delete them from the list....
# Assumes that the "approve" password for each list is stored in a file
# called ".majordomo" in the user's home directory, in the following format:
# 
# 	List		Password	Majordomo-Address
# 
# When you bounce someone from a list, it looks up that lists's password
# and Majordomo-Address (the address of the Majordomo server serving that
# list) in the .majordomo file, and looks for another list named "bounces"
# with the same Majordomo-Address.
# 
# Here's an example of what a .majordomo file should look like:
# 
# 	this-list	passwd1		Majordomo@This.COM
# 	other-list	passwd2		Majordomo@Other.GOV
# 	bounces		passwd3		Majordomo@This.COM
# 	bounces		passwd4		Majordomo@Other.GOV
# 
# A command of "bounce this-list user@fubar.com" will mail the
# following message to Majordomo@This.COM:
# 
# 	approve passwd1 unsubscribe this-list user@fubar.com
# 	approve passwd3 subscribe bounces user@fubar.com (930401 this-list)
# 
# Note that the date and the list the user was bounced from are included
# as a comment in the address used for the "subscribe bounces" command.
# 
# Brent Chapman                                   Great Circle Associates
# Brent@GreatCircle.COM                           1057 West Dana Street
# +1 415 962 0841                                 Mountain View, CA  94041

# $Source: /sources/cvsrepos/majordomo/bounce,v $
# $Revision: 1.1.1.1 $
# $Date: 1993/08/31 16:05:00 $
# $Author: rouilj $
# $State: Exp $
#
# $Locker:  $
#

require "getopts.pl";

&Getopts("df:") ||
    die("USAGE: bounce [-f <config-file>] [-d] <list> <user>\nStopped");

if (! defined($opt_f)) {
    $opt_f = <~/.majordomo>;
}

&read_config();

$list = shift(@ARGV);
$list =~ tr/A-Z/a-z/;
$list =~ s/@.*//;

$list_passwd = $passwd{$list};
if (! $list_passwd) {
    die("no password for list $list; stopping");
}

#$bounce_passwd = $passwd{"bounces@$majordomo{$list}"};
#if (! $bounce_passwd) {
#    die("no password for list bounces; stopping");
#}

local($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime;

if (defined($opt_d)) {
    open(MSG, ">&STDOUT");
} else {
    open(MSG, "|/usr/lib/sendmail $majordomo{$list}") || 
	die("open(MSG, \"|/usr/lib/sendmail $majordomo{$list}\"): $!\nStopped");
}

print MSG <<EOF;
To: $majordomo{$list}

EOF

foreach (@ARGV) {
    printf MSG "approve %s unsubscribe %s %s\n", $list_passwd, $list, $_;
#    printf MSG "approve %s subscribe bounces %s (%02d%02d%02d %s)\n",
#	$bounce_passwd, $_, $year, $mon+1, $mday, $list;
}
close(MSG);

exit 0;

sub read_config {
    open(CONF, $opt_f) || die("open(CONF, \"$opt_f\"): $!");
    while (<CONF>) {
	s/\n$//;
	s/#.*//;
	if (/^$/) { next; }
	split;
	$_[0] =~ tr/A-Z/a-z/;
	$_[2] =~ tr/A-Z/a-z/;
	$passwd{$_[0]} = $_[1];
	$passwd{"$_[0]@$_[2]"} = $_[1];
	$majordomo{$_[0]} = $_[2];
    }
    close(CONF);
}



















-----
John Sechrest          .         Helping people use
Executive Director       .           computers and Internet
Computer Science Outreach  .            more effectively
Room 8 Hovland Hall          .
Oregon State University          .	     Internet: sechrest@peak.org
Corvallis Oregon 97331               .                  (503) 737-5562
					   . http://www.peak.org/~sechrest

Indexed By Date Previous: "reject" script
From: Derrick Green <eusdegr@wser.ericsson.se>
Next: The "WHO" command
From: Randy Schrock <rschrock@realworks.com>
Indexed By Thread Previous: "reject" script
From: Derrick Green <eusdegr@wser.ericsson.se>
Next: The "WHO" command
From: Randy Schrock <rschrock@realworks.com>

Google
 
Search Internet Search www.greatcircle.com