I now added an eMail-Response in case of failure to print.
This needs a working mail command.
#!/bin/bash
SUPPORTED_FILETYPES=".pdf.jpg.png.tif.gif"
LP_OPTIONS="-o media=A4,tray1 -o fit-to-page -o position=top -o scaling=100"
MAILFILE=~/mailtemp/$(date +%H%M%S).txt
PRINT_FOLDER=~/printable
/usr/bin/fetchmail --bsmtp $MAILFILE
if [ "$?" = "0" ]; then
MAIL_ADDRESS=$(grep 'From:' $MAILFILE | sed -n -e 's/^[^<]*<\([^>]*\)>.*$/\1/p')
/usr/bin/uudeview +e $SUPPORTED_FILETYPES -p $PRINT_FOLDER -i $MAILFILE
rm $MAILFILE
PRINTED="no"
for f in $PRINT_FOLDER/*
do
if [ "$f" != "$PRINT_FOLDER/*" ]; then
LP_OUTPUT=$(lp $LP_OPTIONS $f)
if [ "$?" != "0" ]; then
MAILTEXT="File $f could not be printed."
echo "$MAILTEXT" | mail -s "Print-Error" $MAIL_ADDRESS
fi
rm $f
PRINTED="yes"
else
if [ "$PRINTED" = "no" ]; then
echo "No printable Attachments" | mail -s "Print-Error" $MAIL_ADDRESS
fi
fi
done
~/mailprint
fi
For that to work, you have to add the following line to your .fetchmailrc:
fetchlimit 1
With this line, only one mail is received each time the script is executed.
Therefore the script calls itself again as long as messages are downloaded.


