[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: test im script



Pierre Gillmann wrote:
Aber wie es in einem Skript aussehen könnte, weiß ich jetzt nicht so
genau, da ich auch dein Skript nicht kenne, aber vielleicht helfen dir
meine Beispiele weiter.

Ja tun sie, danke. Mein cron-Skript (lernt Ham-Mails in die globale
bayesdb) sieht so aus:

#!/bin/sh

MAILSPOOL=/var/spool/cyrus/mail/user
CYRUSHOME=/var/spool/cyrus/tmp

test -d $MAILSPOOL/$1/Ham               \
|| { echo $MAILSPOOL/$1/Ham does not exist or is not a directory; exit 0; }

test -d $MAILSPOOL/$1/Ham/learned       \
|| { echo $MAILSPOOL/$1/Ham/learned does not exist or is not a directory; exit 0; }

test -d $CYRUSHOME                      \
|| { echo $CYRUSHOME does not exist or is not a directory; exit 0; }

rm -f   $MAILSPOOL/$1/Ham/cyrus.*
rm -f   $MAILSPOOL/$1/Ham/learned/cyrus.*

mv -f   $MAILSPOOL/$1/Ham/*     $CYRUSHOME/             &> /dev/null
mv -f   $CYRUSHOME/learned      $MAILSPOOL/$1/Ham/      &> /dev/null

if [ -s $CYRUSHOME ]; then
        chmod -f 750    $MAILSPOOL/$1/Ham
        chmod -f 750    $MAILSPOOL/$1/Ham/learned
        chmod -f 750    $CYRUSHOME
        chmod -f 640    $CYRUSHOME/*

        su - mail -c    "sa-learn --ham $CYRUSHOME/*"

sed -i 's/Subject: \*\*\*SPAM-Scheisse\*\*\* /Subject: /g' \
                        $CYRUSHOME/*    &> /dev/null

mv -f $CYRUSHOME/* $MAILSPOOL/$1/Ham/learned/ &> /dev/null
fi

if [ -s $MAILSPOOL/$1/Ham/learned ]; then
        chown cyrus:mail        $MAILSPOOL/$1/Ham/learned/*
        chmod -f 640            $MAILSPOOL/$1/Ham/learned/*
fi

su - cyrus -c "/usr/lib/cyrus/bin/reconstruct -r user.$1.Ham" &> /dev/null

Ich weiss, es ist stark verbesserungswürdig, aber ich fange ja gerade
erst an... ;)

--
Mit freundlichen Gruessen
Bjoern Schmidt



Reply to: