#!/bin/sh #Conference subscription 1.0 Ondrej Moravcik 2008 mkdir /tmp/Testmail$$ cd /tmp/Testmail$$ > testmail sed -ne "p" >> testmail #mail parts separation and information extraction body=`cat testmail | sed -ne '1,/^$/!p'` from=`cat testmail | sed -ne '/^$/,$!p' | sed -ne "s/^[Ff]rom: \(.* \)\?<\?\([^<>]*\)>\?/\2/p"` subj=`cat testmail | sed -ne '/^$/,$!p' | sed -ne "s/^[Ss]ubject: \(.*\)/\1/p"` if echo $subj | grep -qe "^subscribe .*" then subscr=`echo $subj | sed -ne "s/^subscribe \(.*\)/\1/p"` if grep -qe "^$subscr:\( .*\)*" $listkonfer then #echo $subscr: $from | join $listkonfer - > pomlist #toto by jelo na freeBSD sed -e "s/^\($subscr: .*\)/\1 $from/" $listkonfer > pomlist cat pomlist > $listkonfer else echo $subscr: $from > pomlist sort -k1 -t: pomlist >> $listkonfer fi echo "Byl jste prihlasen do konference $subscr" | mail -s 'Prihlaseni do konference' $from fi if echo $subj | grep -qe "^unsubscribe .*" then unsubscr=`echo $subj | sed -ne "s/^unsubscribe \(.*\)/\1/p"` sed -e "/^$unsubscr: $from$/D" $listkonfer > pomlist sed -e "s/^\($unsubscr:\)\( .*\)* $from\( .*\)*/\1\2\3/" $listkonfer > pomlist cat pomlist > $listkonfer echo "Byl jste odhlasen z konference $unsubscr" | mail -s 'Odhlaseni z konference' $from fi if [ "$subj" = list ] then cat $listkonfer | cut -d':' -f1 | mail -s 'Seznam konferenci' $from #cat $listkonfer | cut -d':' -f1 fi if [ `echo $subj | grep "[^:]+: .+"` ] then konf=`echo $subj | sed -ne "s/\([^:]+:\) .+/\1/p"` thema=`echo $subj | sed -ne "s/[^:]+: \(.+/\1\)/p"` to=`cat $listkonfer | sed -ne "s/^$konf \(.*\)/\1/p"` if [ "r$to" != r ] then #echo body echo $body | mail -s "$thema" $to fi fi rm -R /tmp/Testmail$$