Hylafax Mailing List Archives
|
[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
[hylafax-users] A notify script to attach FAX to email
I saw the post with the modified notify.awk script:
http://www.hylafax.org/archive/2003-06/msg00190.html
It seemed a little busy to me with all that mime encoding in the file. So I cooked my own version which I think it a little
cleaner (and maybe could be good enough to be part of the distribution). I modified the awk script
only slightly but added a fair amount to the notify script. It will send a regular email as before unless metamail is installed.
If it finds metamail, it will send a mime-encoded email with the FAX as an attachment. As long as your email agent knows how
to open a postscript, you can click on attachments and easily see which fax failed.
This also solves the issue some have discussed on the mailing list about resubmitting a failed FAX to the queue again. You can
simply save the attachments to a folder and run the command (as instructed by your email notice) to requeue the document (possibly
with a corrected fax number.
I also had a bug (on fedora core 1 Linux) with the line in the awk script:
"wc -c" files[i] | getline;
which produces a permission error (still not sure why). I changed it to 2 separate lines as shown in the patch and it works
better. Maybe something to do with my version of awk or something...
Here are the patches to notify.awk and notify (fwiw).
--- notify.awk.org 2004-03-31 09:30:23.000000000 -0700
+++ notify.awk 2004-03-31 15:13:10.000000000 -0700
@@ -92,15 +92,13 @@
printItem("%u (directory of next page to send)", "Dirnum", dirnum);
if (nfiles > 0) {
printBanner("Documents submitted for transmission");
- print "The following documents were submitted for transmission and are";
- print "available on the server for reuse until they are automatically";
- print "purged when this job is " doneop "d. Documents may also be
manually";
- print "removed using the faxrm command; consult faxrm(1) for
information.";
+ print "The following documents were submitted for transmission:";
print ""
- printf "%-20s %8s %s\n", "Filename", "Size", "Type";
+ printf " %-20s %8s %s\n", "Filename", "Size", "Type";
for (i = 0; i < nfiles; i++) {
- "wc -c " files[i] | getline;
- printf "%-20s %8d %s\n", files[i], $1, docType(files[i]);
+ cmd = "wc -c " files[i];
+ cmd | getline;
+ printf "File: %-20s %8d %s\n", files[i], $1, docType(files[i]);
close("wc -c " files[i]);
}
}
--- notify.org 2004-03-31 14:02:23.000000000 -0700
+++ notify 2004-04-01 14:17:04.000000000 -0700
@@ -58,11 +58,62 @@
JTIME=$3
NEXT=${4:-'??:??'}
-($AWK -F: -f bin/notify.awk why=$WHY jobTime=$JTIME nextTry=$NEXT
$QFILE || {
- echo ""
- echo "Sorry, there was a problem sending notification;"
- echo "something went wrong in the shell script $0."
- echo ""
- exit 1;
- }
-) | 2>&1 $SENDMAIL -t -ffax -oi
+tfile="tmp/$(basename $QFILE).txt"
+ffile="tmp/$(basename $QFILE).fil"
+atts=""
+docs=""
+
+if ! $AWK -F: -f bin/notify.awk why=$WHY jobTime=$JTIME nextTry=$NEXT
$QFILE >$tfile; then
+ echo "Sorry, there was an error while sending notification;"
>>$tfile
+ echo "something went wrong in the script: $0."
>>$tfile
+ cat $tfile | $SENDMAIL -t -ffax -oi
+elif ! which metasend 2>/dev/null; then
+ cat $tfile | $SENDMAIL -t -ffax -oi
+else
+ to="$(grep '^To: ' $tfile |sed -e '2,$d' -e 's/To: //')"
+ subj="$(grep '^Subject: ' $tfile |sed -e '2,$d' -e 's/Subject: //')"
+ dest="$(grep '^Subject: ' $tfile |sed -e '2,$d' -e 's/Subject: //')"
+ dest="$(grep '^[ ]*Destination: ' $tfile |sed -e '2,$d' -e 's/[
]*Destination: //')"
+ grep '^File: ' $tfile >$ffile
+#echo "to:$to subj:$subj dest:$dest"
+ page=1
+ while read junk file size type rest; do
+#echo "file:$file size:$size type:$type rest:$rest"
+ if [ "$type" = "PostScript" ]; then
+ mime="application/postscript"
+ ext=ps
+ elif [ "$type" = "TIFF" ]; then
+ mime="image/tiff"
+ ext=tif
+ else
+ mime="text/plain"
+ ext=txt
+ fi
+ if [ "$rest" = "" ]; then
+ rest="Page_$page.$ext"
+ else
+ rest="$(echo "$rest" | tr ' ' '_').$ext"
+ fi
+ docs="$docs $rest"
+#echo "rest:$rest"
+ atts="$atts -n -f $file -e base64 -m $mime;name=$rest"
+ page=$(expr $page + 1)
+ done <$ffile
+
+ cat >>$tfile <<-EOT
+
+ You can requeue these documents by saving them all to a folder
+ and then while in that folder, execute the following command in
+ a shell window:
+
+ sendfax -n -d $dest $docs
+ EOT
+
+ echo "This is a multi-part message in MIME format." >tmp/preamble.mm
+#echo \
+ metasend -t $to -F fax -b -P tmp/preamble.mm -s "$subj" -S 10000000 \
+ -f $tfile -e 7bit -m "text/plain; name=\"Notify Text\"" $atts
+ rm $ffile
+fi
+
+rm $tfile
____________________ HylaFAX(tm) Users Mailing List _______________________
To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe hylafax-users-request@xxxxxxxxxxx < /dev/null
*To learn about commercial HylaFAX(tm) support, mail sales@xxxxxxxxx*