![]() |
# # notify qfile why jobtime [nextTry] # # Return mail to the submitter of a job when notification is needed. # if [ $# != 3 -a $# != 4 ]; then echo "Usage: $0 qfile why jobtime [nextTry]" exit 1 fi
test -f etc/setup.cache || { SPOOL=`pwd` cat<<EOF
The file $SPOOL/etc/setup.cache is not present. This probably means the machine has not been setup using the faxsetup(8C) command. Read the documentation on setting up HylaFAX before you startup a server system.
EOF exit 1 } . etc/setup.cache
QFILE=$1 WHY=$2 JTIME=$3 NEXT=${4:-'??:??'}
# # Awk support program for notify shell script. This # stuff is broken out into a separate file to avoid # overflowing the exec arg list on some systems like SCO. #
function printItem(fmt, tag, value) { printf "%14s: " fmt "\n", tag, value; }
function printBanner(banner) { print ""; print " ---- " banner " ----"; print ""; }
function docType(s) { if (match(s, "\.cover")) return "PostScript cover page"; else if (match(s, "\.ps")) return "PostScript"; else if (match(s, "\.tif")) return "TIFF"; else if (match(s, "\.pdf")) return "PDF"; else if (match(s, "\.pcl")) return "PCL"; else return "Unknown document type"; }
function returnTranscript() { printBanner("Transcript of session follows"); comFile = "log/c" commid; if ((getline <comFile) > 0) { do { if (index($0, "-- data") == 0) print $0 } while ((getline <comFile) > 0); close(comFile); } else { printf " No transcript available"; if (commid != "") printf "(CommID c" commid ")"; print "."; } }
function printStatus(s) { if (s == "") print "<no reason recorded>"; else print s }
function putHeaders(subject) { print "To: " mailaddr; print "Subject: " subject; print ""; printf "Your " jobType " job to " number; }
BEGIN { nfiles = 0; npins = 0; pagewidth = 0; pagelength = 0; resolution = 0; jobType = "facsimile"; signalrate = "unknown"; dataformat = "unknown"; doneop = "default"; pagernum = "unknown"; commid = ""; } /^jobid/ { jobid = $2; } /^groupid/ { groupid = $2; } /^state/ { state = $2+0; } /^doneop/ { doneop = $2; } /^number/ { number = $2; } /^external/ { number = $2; } # override unprocessed number /^sender/ { sender = $2; } /^mailaddr/ { mailaddr = "duke_justice@xxxxxxxxxxxx"; } /^jobtag/ { jobtag = $0; sub("jobtag:", "", jobtag); } /^jobtype/ { jobType = $2; } /^status/ { status = $0; sub("status:", "", status); if (status ~ /\\$/) { sub("\\\\$", "\n", status); while (getline > 0) { status = status $0; sub("\\\\$", "\n", status); if ($0 !~ /\\$/) break; } } } /^resolution/ { resolution = $2; } /^npages/ { npages = $2; } /^totpages/ { totpages = $2; } /^dirnum/ { dirnum = $2; } /^commid/ { commid = $2; } /^ntries/ { ntries = $2; } /^ndials/ { ndials = $2; } /^pagewidth/ { pagewidth = $2; } /^pagelength/ { pagelength = $2; } /^signalrate/ { signalrate = $2; } /^dataformat/ { dataformat = $2; } /^modem/ { modem = $2; } /^totdials/ { totdials = $2; } /^tottries/ { tottries = $2; } /^client/ { client = $2; } /^[!]*post/ { files[nfiles++] = $4; } /^[!]*tiff/ { files[nfiles++] = $4; } /^[!]*pcl/ { files[nfiles++] = $4; } /^page:/ { pins[npins++] = $4; } /^[!]page:/ { pagernum = $4; } /^data:/ { files[nfiles++] = $4; } /^poll/ { poll = " -p"; } END { if (jobtag == "") jobtag = jobType " job " jobid;; if (doneop == "default") doneop = "remove"; if (jobType == "pager") number = pagernum; if (why == "done") { putHeaders(jobtag " to " number " completed"); print " was completed successfully."; print ""; if (jobType == "facsimile") { printItem("%u", "Pages", npages); if (resolution == 196) printItem("%s", "Quality", "Fine"); else printItem("%s", "Quality", "Normal"); printItem("%u (mm)", "Page Width", pagewidth); printItem("%.0f (mm)", "Page Length", pagelength); printItem("%s", "Signal Rate", signalrate); printItem("%s", "Data Format", dataformat); } if (tottries != 1) printItem("%s (exchanges with remote device)", "Dialogs", tottries); if (totdials != 1) printItem("%s (total phone calls placed)", "Calls", totdials); if (modem != "any") printItem("%s", "Modem", modem); printItem("%s", "Submitted From", client); printItem("%s", "JobID", jobid); printItem("%s", "GroupID", groupid); printItem("%s", "CommID", "c" commid); printf "\nProcessing time was " jobTime ".\n"; if (status != "") { print " Additional information:\n " status; returnTranscript(); } } else if (why == "failed") { putHeaders(jobtag " to " number " failed"); printf " failed because:\n "; printStatus(status); returnTranscript(); returnToSender(); } else if (why == "rejected") { putHeaders(jobtag " to " number " failed"); printf " was rejected because:\n "; printStatus(status); returnToSender(); } else if (why == "blocked") { putHeaders(jobtag " to " number " blocked"); printf " is delayed in the scheduling queues because:\n "; printStatus(status); print ""; print "The job will be processed as soon as possible." } else if (why == "requeued") { putHeaders(jobtag " to " number " requeued"); printf " was not sent because:\n "; printStatus(status); print ""; print "The job will be retried at " nextTry "." returnTranscript(); } else if (why == "removed" || why == "killed") { putHeaders(jobtag " to " number " removed from queue"); print " was deleted from the queue."; if (why == "killed") returnToSender(); } else if (why == "timedout") { putHeaders(jobtag " to " number " failed"); print " could not be completed before the appointed deadline."; returnToSender(); } else if (why == "format_failed") { putHeaders(jobtag " to " number " failed"); print " was not sent because document conversion" print "to facsimile failed. The output from the converter program was:\n"; print status "\n"; printf "Check any PostScript documents for non-standard fonts %s.\n", "and invalid constructs"; returnToSender(); } else if (why == "no_formatter") { putHeaders(jobtag " to " number " failed"); print " was not sent because"; print "the document conversion script was not found."; returnToSender(); } else if (match(why, "poll_*")) { putHeaders("Notice about " jobtag); printf ", a polling request,\ncould not be completed because "; if (why == "poll_rejected") print "the remote side rejected your request."; else if (why == "poll_no_document") print "no document was available for retrieval."; else if (why == "poll_failed") print "an unspecified problem occurred."; print ""; printf "Processing time was %s.\n", jobTime; returnTranscript(); } else { putHeaders("Notice about " jobtag); print " had something happen to it." print "Unfortunately, the notification script was invoked", "with an unknown reason" print "so the rest of this message is for debugging:\n"; print "why: " why; print "jobTime: " jobTime; print "nextTry: " nextTry; print ""; print "This should not happen, please report it to your administrator."; returnTranscript(); returnToSender(); } }
____________________ 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@xxxxxxxxxxxx*