#!/bin/bash # # Name: emailfax # Author: Colin Anderson <[EMAIL PROTECTED]> # Desc: Script to email faxes from SpanDSP and detect if fax is corrupt or incompatible with SpanDSP
# These three variables must be passed to the script for it to work FAXFILE=$1 EMAILADDRESS=$2 CALLERID=$3 # First we convert the fax to a PDF wheter it's good, bad or whatever /bin/nice -n 19 tiff2ps -2eaz -w 8.5 -h 11 $FAXFILE | ps2pdf - $FAXFILE.pdf # Then we stat the filesize of the generated PDF. A corrupt PDF usually comes through as 422 bytes PDFSIZE=`stat -c%s $FAXFILE.pdf 2> /dev/null` # If-then to email the fax if it's OK, or email the recipient to let them know that the fax was bad, # and we will add it to our exception list (manually) so it will go to a real fax machine in the future # If the filesize of the PDF is greater than 422 bytes send it otherwise uh-oh. if [ $PDFSIZE -gt 422 ]; then mime-construct --to $EMAILADDRESS --subject "Fax from $CALLERID" --attachment $CALLERID.pdf --type application/pdf --file $FAXFILE.pdf rm $FAXFILE rm $FAXFILE.pdf else # I use mime-consruct because I'm lazy but a piped mail command should work just as well. mime-construct --to $EMAILADDRESS --subject "Fax from $CALLERID failed to receive properly - this fax number will be added to the exception list" mime-construct --to [EMAIL PROTECTED] --subject "Fax from $CALLERID failed - fix dat shit" rm $FAXFILE rm $FAXFILE.pdf fi _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- Asterisk-Users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users