A cronscript

#!/bin/sh
FNDIR="train-as-spam"
FPDIR="train-as-ham"

for dir in /home/*/.maildir
do
    cd "${dir}"
    USER=`stat -c %U .`

    SRCDIR="${dir}/.${FNDIR}"
    if [ ! -d ${SRCDIR} ]; then
        echo no "${SRCDIR}" directory
    else
        cd "${SRCDIR}/cur"
        ls -tr | while read file
        do
            if grep -q "^X-DSPAM" "${file}"; then
                SOURCE="error"
            else
                SOURCE="corpus"
            fi

            dspam --user "${USER}" --class=spam --source="${SOURCE}" --deliver=innocent,spam --stdout < "${file}" > "../tmp/${file}"
            mv "../tmp/${file}" "${dir}/new/${file%%:*}" && rm "${file}"
        done
    fi

    SRCDIR="${dir}/.${FPDIR}"
    if [ ! -d ${SRCDIR} ]; then
        echo no "${SRCDIR}" directory
    else
        cd "${SRCDIR}/cur"
        ls -tr | while read file
        do
            if grep -q "^X-DSPAM" "${file}"; then
                SOURCE="error"
            else
                SOURCE="corpus"
            fi

            dspam --user "${USER}" --class=innocent --source="${SOURCE}" --deliver=innocent,spam --stdout < "${file}" > "../tmp/${file}"
            mv "../tmp/${file}" "${dir}/new/${file%%:*}" && rm "${file}"
        done
    fi

done

last edited 2007-04-28 11:57:45 by JohnNilsson