[Mailman-Users] Scripting newlist gives weird errors!

hesco at greens.org hesco at greens.org
Wed Sep 1 05:19:21 CEST 2004


I'm developing a script to automate list creation, particularly
alias creation.  I'm running into weird errors.  

All clues are appreciated.  

Using the mm scripts at a command line as intended seems to work
fine.  But when I try to call it from a script, it hangs and
fails to return cleanly so my script can continue to execute.

bash-2.05$ newlist testy hesco at greens.org qwerty
To finish creating your mailing list, you must edit your
/etc/aliases (or equivalent) file by adding the following lines,
and possibly running the `newaliases' program:

## testy mailing list
testy:              "|/home/mailman/mail/mailman post testy"
testy-admin:        "|/home/mailman/mail/mailman admin testy"
testy-bounces:      "|/home/mailman/mail/mailman bounces testy"
testy-confirm:      "|/home/mailman/mail/mailman confirm testy"
testy-join:         "|/home/mailman/mail/mailman join testy"
testy-leave:        "|/home/mailman/mail/mailman leave testy"
testy-owner:        "|/home/mailman/mail/mailman owner testy"
testy-request:      "|/home/mailman/mail/mailman request testy"
testy-subscribe:    "|/home/mailman/mail/mailman subscribe testy"
testy-unsubscribe:  "|/home/mailman/mail/mailman unsubscribe testy"

Hit enter to notify testy owner...


I get the newlist email and everything works as intended.

The only problem is that I am not root on this machine.  So I
have a script set up to install my new aliases, which is run
by root crontab on 15 minute intervals.  It sweeps them out
of aliases.tmp and puts them in /etc/mail/aliases.

And I will need to create over a hundred-fifty lists in a couple
of weeks which will only be used for a couple of months.  So,
I'm trying to automate this as much as possible, especially
all that alias creation.  First the strange errors I get from
the python newlist script, then the perl script which invokes
newlist to generate these errors.

bash-2.05$ ./nl.pl testier hesco at greens.org qwerty
List = testier
Admin = hesco at greens.org
Password = qwerty

Create List Command:  /home/mailman/bin/newlist testier hesco at greens.org qwerty

^CTraceback (most recent call last):
  File "/home/mailman/bin/newlist", line 219, in ?

bash-2.05$     main()
  File "/home/mailman/bin/newlist", line 191, in main


The new aliases got created and put into temporary storage.
Running $result = `$createlist`; the list got created in the
file system.  I can browse to the listinfo page.  But the
email never shows up for the new list's administrator.
And the script hangs, instead of successfully completing, so
it can re-iterate on the next list it must produce.  Only ^C^C
breaks it out of its holding pattern on the errors reported
above.  My test lists started out being called simply test.
Only banging my head against this one for the last two hours
got them renamed testy and finally testier.

use strict;
my ($NEWLIST, $newaliases, $createlist, $result, $args, $usage);
my ($newlist, $admin, $pw);

$result = `cd /usr/home/hesco`;
$NEWLIST = "/home/mailman/bin/newlist";
$usage = usage();

$newlist = $ARGV[0];
$admin = $ARGV[1];
$pw = $ARGV[2];

print "List = $newlist \nAdmin = $admin \nPassword = $pw \n\n";

if (!$newlist || !$admin || !$pw) {
  print "$usage \n";
  return 0;
} else {
  $createlist = "$NEWLIST $newlist $admin $pw";
  print "Create List Command:  ".$createlist."\n";
  $newaliases = newaliases();
  # print $newaliases;
  $result = `/bin/echo \"$newaliases\" >> aliases.tmp`;
  $result = `$createlist`;

  print "List created and aliases prepared.  \n";
  print "Run sudo installaliases.sh to activate aliases and list.";
  print "\n\n";

  1;  # return true

sub usage() {
  $usage = "Usage:  ,/nl.pl newlistname admin-email admin-pw \n\n";
  return $usage;

sub newaliases() {
  $newaliases = qq{
\#\# $newlist mailing list
$newlist:              \\\"|/usr/local/mailman/mail/mailman post $newlist\\\"
$newlist-admin:        \\\"|/usr/local/mailman/mail/mailman admin $newlist\\\"
$newlist-bounces:      \\\"|/usr/local/mailman/mail/mailman bounces $newlist\\\"
$newlist-confirm:      \\\"|/usr/local/mailman/mail/mailman confirm $newlist\\\"
$newlist-join:         \\\"|/usr/local/mailman/mail/mailman join $newlist\\\"
$newlist-leave:        \\\"|/usr/local/mailman/mail/mailman leave $newlist\\\"
$newlist-owner:        \\\"|/usr/local/mailman/mail/mailman owner $newlist\\\"
$newlist-request:      \\\"|/usr/local/mailman/mail/mailman request $newlist\\\"
$newlist-subscribe:    \\\"|/usr/local/mailman/mail/mailman subscribe $newlist\\\"
$newlist-unsubscribe:  \\\"|/usr/local/mailman/mail/mailman unsubscribe $newlist\\\"
  return $newaliases;
}  # END newaliases

More information about the Mailman-Users mailing list