[Mailman-Users] How to import a list of members?

Lynn, Michael (A&E) michael_lynn at ml.com
Fri Apr 25 12:31:13 CEST 2008


Not sure if this will help anyone - but I had a requirement to enable
remote subscription from a command line.  I wrapped a call to cURL for
this.

--->8---
#!/bin/bash
# mlynn 03/28/2008
# Wrap a call to curl to enable subscription to a mailman list
#
VERSION="0.1"
MAILMANURL="http://lists.yourserver.com/mailman/subscribe"
PROGRAM=`basename $0`

function ERROR
# Spew the wrongness
{
        echo "Error: Code $1"
        echo "${2}?"
        exit $1
}

function SYNTAX
#
# Tell the people how you communicate
#
{
        echo "SYNTAX:"
        echo "$PROGRAM $VERSION"
        echo "  $PROGRAM [[email] [firstname] [lastname] [password]
[listname]]"
        echo "  This handy script will wrap a call to cURL for the
purpose of subscribing"
        echo "  a user to a mailman list.  If you fail to provide
optional arguments, you"
        echo "  will be prompted to enter them at the command line."
        echo "           "
}

function CHECKCURL
#
# Check for commands you depend upon
#
{
        CURL=`which curl`
        if [ $? -ne 0 ]; then
                ERROR 1 "the command curl is missing from the system"
        fi;

}

function GETARGS
#
# Get the arguments - duh.
#
{
        if [ "$1" = "-h" -o "$1" = "--h" ]; then
                SYNTAX
                exit 0
        fi
        if [ -z $1 ]; then
                {
                echo "Enter email for user to be subscribed: "
                read EMAIL
                if [ -z $EMAIL ]; then
                        ERROR 30 "You must enter a valid email address."
                fi
                }
        else
                EMAIL=$1
        fi
        if [ -z $2 ]; then
                {
                echo "Enter the first name of the person to be
subscribed: "
                read FIRSTNAME
                if [ -z $FIRSTNAME ]; then
                        ERROR 30 "You the first name of the subscibee."
                fi
                }
        else
                FIRSTNAME=$2
        fi
        if [ -z $3 ]; then
                {
                echo "Enter the last name of the person to be
subscribed: "
                read LASTNAME
                if [ -z $LASTNAME ]; then
                        ERROR 30 "You the last name of the subscibee."
                fi
                }
        else
                LASTNAME=$3
        fi
        if [ -z $4 ]; then
                {
                echo "Enter the list access password for this user: "
                read PW
                if [ -z $PW ]; then
                        ERROR 30 "You must enter a password for $EMAIL."
                fi
                }
        else
                PW=$4
        fi
        if [ -z $5 ]; then
                {
                echo "Enter the list name to subscribe $EMAIL to: "
                read LIST
                if [ -z $LIST ]; then
                        ERROR 30 "You must enter a valid listname."
                fi
                }
        else
                LIST=$5
        fi
}

function DOCURL
# Build the cURL call
{

        # urlencode the email '@'
        UEMAIL=`echo $EMAIL | sed "s/\@/\%40/g"`
        CMD="curl -s
$MAILMANURL/${LIST}?email=${UEMAIL}&fullname=$FIRSTNAME%20$LASTNAME&pw=$
PW&pw-conf=$PW&digest=0&email-button=Submit"
        OUT=`${CMD}`
        if `echo ${OUT} | grep -i "no such list"` ; then
                {
                        ERROR 30 "List $LIST not found.  Please check
and try again."
                }
        else
                {
                        echo "List subscription for the following user
appears to have worked."
                        echo "Email:     $EMAIL"
                        echo "Full Name: $FIRSTNAME $LASTNAME"
                        echo "The user should recieve an email
requesting confirmation for this subscription."
                        exit 0
                }
        fi

}


CHECKCURL
GETARGS $1 $2 $3 $4 $5
DOCURL
---8<----

-----Original Message-----
From: mailman-users-bounces+michael_lynn=ml.com at python.org
[mailto:mailman-users-bounces+michael_lynn=ml.com at python.org] On Behalf
Of lists.mailman-users at duinheks.nl
Sent: Friday, April 25, 2008 4:47 AM
To: mailman-users
Subject: Re: [Mailman-Users] How to import a list of members?


Hallo Zbigniew,

Op vrijdag 25 april 2008 schreef Zbigniew Szalbot aan
lists.mailman-users at duinheks.nl:

 >> Is it possible to import an ASCII list of members for a
 >> mailing list?
 ZS> Take a look at bin/add_members script
 ZS> Run it with --help to see what options there are

Lovely! That seems to de exactly what I want. Thank tou very
much for your help.

Groeten,

           Hans.

jdh punt beekhuizen bij duinheks punt nl

--- GoldED+/LNX 1.1.5/080305
 * Origin: The Wizard is using MBSE/Linux (2:280/1018)
------------------------------------------------------
Mailman-Users mailing list
Mailman-Users at python.org
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/
Unsubscribe:
http://mail.python.org/mailman/options/mailman-users/michael_lynn%40ml.c
om

Security Policy:
http://www.python.org/cgi-bin/faqw-mm.py?req=show&amp;file=faq01.027.htp
--------------------------------------------------------

This message w/attachments (message) may be privileged, confidential or proprietary, and if you are not an intended recipient, please notify the sender, do not use or share it and delete it. Unless specifically indicated, this message is not an offer to sell or a solicitation of any investment products or other financial product or service, an official confirmation of any transaction, or an official statement of Merrill Lynch. Subject to applicable law, Merrill Lynch may monitor, review and retain e-communications (EC) traveling through its networks/systems. The laws of the country of each sender/recipient may impact the handling of EC, and EC may be archived, supervised and produced in countries other than the country in which you are located. This message cannot be guaranteed to be secure or error-free. This message is subject to terms available at the following link: http://www.ml.com/e-communications_terms/. By messaging with Merrill Lynch you consent to the foregoing.
--------------------------------------------------------


More information about the Mailman-Users mailing list