#!/bin/sh if [ ! "$1" ] then echo "need dir" exit 1 fi for file in $(find $1 -name rejected -prune -o -name .mh_sequences -prune -o -type f -print) do from_count=$(grep '^From:[[:space:]]' $file | wc -l) if [ $from_count -gt 2 ] then echo "TOO MANY FROM $from_count -- $file" fi if [ $from_count -lt 1 ] then echo "NO FROM -- $file" fi if [ ! "$(cat $file | formail -XMessage-ID:)" ] then echo "NO MESSAGEID -- $file" fi DATE1=`cat $file | formail -xDate: | head -1` DATE=`if [ -z "$DATE1" ]; then cat $file | formail -x'From ' | cut -d' ' -f 3-; else echo $DATE1; fi` # Sometimes people use timezone stuff we don't understand, so # strip off the end FIXED_DATE=`echo $DATE | sed 's/\s\s*[A-Z][A-Z0-9+:-]*\s*$//' | sed 's/\s\s*[+-][0-9]*\s*$//' | sed 's/\s\s*0*\s*$//'` DTAG1=`(date -d "$DATE" +%Y-%m 2>&1 || date -d "$FIXED_DATE" +%Y-%m 2>&1 || echo NODA-TE) | tail -1` DTAG=`if [ -z "$DATE" -o -z "$DTAG1" ]; then echo NODA-TE; else echo $DTAG1; fi` if [ ! "$DTAG" -o "$DTAG" == "NODA-TE" ] then echo "NO DATE -- $file" fi done