send mail when failed

This commit is contained in:
Thomas Ruoff
2021-01-31 23:16:05 +01:00
parent 31e98559a3
commit efb1f26477

22
run.sh
View File

@@ -13,7 +13,7 @@ FAILED_DIR=$SRC_DIR/failed
LOG_DIR=$SRC_DIR/logs
PROCESSED_COUNT=0
FAILED_COUNT=0
FAILED_FILES=
function ocrFile() {
SRC=$1
@@ -52,7 +52,7 @@ do
echo failed to process "$FILE"
mv "$FILE" "$FAILED_DIR"
echo moved "$FILE" to "$FAILED_DIR"
(( FAILED_COUNT+=1 ))
FAILED_FILES+=${FILE}\n
fi
echo
done < <(find "$SRC_DIR" -maxdepth 1 -name '*.pdf' -print0)
@@ -61,8 +61,22 @@ echo Done
echo
echo processed "$PROCESSED_COUNT" PDFs
if (( FAILED_COUNT > 0 ))
if [ -n "$FAILED_FILES" ]
then
echo failed on "$FAILED_COUNT" PDFs
echo failed on PDFs
echo "$FAILED_FILES"
sendmail -t thomasruoff@gmail.com <<MAILTEXT
Subject: [$hostname] OCR on PDFs failed
Hey,
following PDFs failed to be OCR'd:
${FAILED_FILES}
Cheers
MAILTEXT
fi