#! /usr/bin/perl -w # Perl routine: sympa-smartlist.pl 18 November 1999. # # This Perl script makes Sympa resemble Smartlist. # In Smartlist, the word "subscribe" in the subject field can be # sent to the address: LISTNAME-request@LISTSERVER. # Sympa was modified in late 1999, and now Sympa can now imitate being # a Smartlist list. So the script would be no longer needed except.. # # Sympa had a Bug # # After Sept 1999, Sympa had a bug, which was that the command "review" # in the subject field did Not result in Sympa doing a review when the # command was sent to LISTNAME-request@LISTHOST # # ----------------------- # What it is that this script does: An e-mail message is piped into it. # It then scans for the 'Subject:' line, and then it inserts the first # token of its command line arguments, into the Subject line just # after the 2nd token in that subject line. It then pipes that into # the Sympa 'queue' program, which then writes the message as a file. # # Sympa has a homepage at http://listes.cru.fr/sympa/ # This script has not been tested much # Bug fixed (18Nov): Info command understood; it expects a listname # # USAGE: # LISTNAME-request : "|/etc/smrsh/sympa-smartlist.pl LISTNAME" # cd /etc/smrsh # ln -s /home/sympa/bin/sympa-smartlist.pl # cd /home/sympa/bin/ # chmod a+x sympa-smartlist.pl # chmod u+s sympa-smartlist.pl # (Wrong permissions can stop the Sympa system running) # *** Edit $HOMEQUEUE below # # Test the script: # 1: cat test.txt | /etc/smrsh/sympa-smartlist.pl testscript # Output should appear on the standard output # 2: cat test.txt | /etc/smrsh/sympa-smartlist.pl LISTNAME # Program Queue should a create a file in directory ../expl/msg # If the script does not run, Sendmail will say "unknown mailer error 255" my($QUEUEPROGRAM) = "/home/sympa/bin/queue"; # The directory where queue is. No trailing "/". use strict; my($notdone, $NameOfSympaList, $buf) = (1, "UNKNOWN-LIST", ""); if ((defined $ARGV[0]) && ("" ne $ARGV[0])) { $NameOfSympaList = $ARGV[0]; } if (not ($NameOfSympaList =~ m/testscript/i)) { open(STDOUT, "| $QUEUEPROGRAM sympa"); # pipe output into Sympa Mailing List } while (1) { $buf = ; if (not defined $buf) { last; } if ($notdone) { $buf =~ /^\s*(Subject:)\s*(\S+) *(.*)$/is; # /s makes $3 incl line-end-char(s) if (defined $2) { $notdone = 0; my ($header, $cmd, $cmdarg) = ($1, $2, $3); if ( ($cmd =~ # these commands accept LISTNAME as 1st arg to $cmd: /( INFO| REView|REVie|REVi|REV| SUBscribe|SUBscrib|SUBscri|SUBscr|SUBsc|SUBs|SUB| UNSubscribe|UNSubscrib|UNSubscri|UNSubscr|UNSubsc|UNSubs|UNSub|UNSu|UNS| SET| INDex|INDe|IND| GET| ADD| DEL| STATS|STAT|STA| DIStribute|DIStribut|DIStribu|DIStrib|DIStri|DIStr|DISt|DIS| REJect|REJec|REJe|REJ| MODINDEX| EXPire|EXPir|EXPi|EXP| EXPireINDex|EXPireINDe|EXPireIND|EXPIND| EXPireDEL|EXPDEL| REMIND)(?!\w) /ix) # i=case_insensitive, x=extend && (not ($cmdarg =~ m/(-request$|-list)/i) ) && (not ($cmdarg =~ m/^...\*/ ) ) # unsubscribe/set ) { $buf = $header . " " . $cmd . " ". $NameOfSympaList . (0 == length($cmdarg) ? "" : " ") . $cmdarg; } } } print $buf; } # ------------ # symp-list : "|/etc/smrsh/queue symple-list" # symp-list-request : "|/etc/smrsh/sympa-smartlist.pl symp-list" # symp-list-subscribe : "|/etc/smrsh/queue symp-list-subscribe" # symp-list-unsubscribe : "|/etc/smrsh/queue symp-list-unsubscribe" # symp-list-editor : "|/etc/smrsh/queue symp-list-editor" # symp-list-bounce : "|/etc/smrsh/Bounce.pl symp-list" # symp-list-owner : sympa-list-owner # symp-request : symp-list-request #... # ------------ # This code is free (etc.) and it is by Craig Carey, research@ijs.co.nz [14-Jan-00]