#! /usr/bin/perl -w # Perl routine: sympa2smartlist.pl 17 August 1999. # Licence: Public domain # This perl script does this: an e-mail message is piped # into it. It scans for the 'Subject:' line, and then # it inserts the the first token of its command line # arguments, into the Subject line just after the 2nd # token in that line. That allows the Sympa mailing list # to resemble the "-request" style of the Smartlist mailing # list better. # Sympa has a homepage at http://listes.cru.fr/sympa/ # # This script has not been tested much use strict; my($notdone, $NameOfSympaList, $buf) = (1, "UNKNOWN-LIST", ""); if ((defined $ARGV[0]) && ("" ne $ARGV[0])) { $NameOfSympaList = $ARGV[0]; } open(STDOUT, "| /home/sympa/bin/queue 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: /(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; } # ------------ # s5 : "|/etc/smrsh/queue s5" # s5-editor : "|/etc/smrsh/queue s5-editor" # s5-bounce : "|/usr/local/Bounce.pl s5" # s5-subscribe : "|/etc/smrsh/queue s5-subscribe" # s5-unsubscribe : "|/etc/smrsh/queue s5-unsubscribe" # # s5-request: "|/etc/smrsh/Sympa2SmartList.pl" # ------------