HylaFAX The world's
most advanced open source fax server
|
|
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
Re: pollrecvd & running scripts for every incoming fax...
well, i'm kind-of relying on the auto-indexer on the archive to help out
any fellow travellers ;-)
so here goes...
the goal was to get autodelivery of PDF image-layer files for incoming
faxes.
the key script that gets run for every incoming fax is etc/faxrcvd,
which gets run every time a fax comes in, so this needed modification
(what i ended up with is included below...i make no claims for elegance,
but it works...feel free to hack and/or add to the distribution or
contrib directory)...
--
note that i've used the tiff2ps utility from tifflib (located at
http://kubax9.kub.nl:2080/Decomate-1.0/tiff-v3.4-tar.gz), rather than
fax2ps included with hylafax, as it seems to generate higher-quality,
though fatter, PostScript, and used ps2pdf from GhostScript 5.50. Also
needed is mimencode, which comes as standard with RH 5.1, on which I'm
running...this is to base64-convert the resulting PDF file for mail
delivery...
--
anyway, here's the code...there are probably numerous security race
risks in my use of tmp/ files, so if anyone has a better idea, please
let me know...
--
(i've also changed the Sender name to fit our potenital use of it here,
so you'll need to change that)
cheers
David Anderson wrote:
>
> OK, now do the right thing and document what you did so each of us
> do not have to go down the same path and get lost along the way.
>
> Thanks
>
> -----Original Message-----
> From: Darrell Berry <darrell@ku24.com>
> To: Darrell Berry <darrellb@hhcl.com>
> Cc: flexfax@sgi.com <flexfax@sgi.com>
> Date: Saturday, December 26, 1998 8:21 PM
> Subject: Re: flexfax: pollrecvd & running scripts for every incoming fax...
>
> >ok, solved...its just a matter of editing faxrecvd...thank god for good
> >design!
> >
> >as usual with open source stuff, its done so it can be built on...i now
> >have exactly what i want...beausitful PDF faxes automatically
> >distributed...thank you all for you kind assistance
> >
> >
> >Darrell Berry wrote:
> >>
> >> i'm still pursuing my mail-delivery of pdf-formatted faxes, and am now
> >> looking at how to schedule the checking and sending...basically what i
> >> want to do is similar to the fucntion of bin/pollrecd...in fact
> >> pollrecvd goes one furth and reports back on partically recieved faxes,
> >> which is great...hoewver i don't quite understand what calls
> >> pollrecd...is it only run when a poll command is issued manually?
> >>
> >> if so, is there a server-side stub somewhere where a script can be caled
> >> EVERY TIME a fax is received? Or do I have to write a cron job that
> >> looks at the seqf in log/ and does it itself...and if so, how do i link
> >> the cxxxxxxx files to actual tif files in recvq?
> >>
> >> so many questions...sorry!
> >>
> >> all i realy want to do, is run something like pollrecvq everytime a fax
> >> (or partial fax) comes in, sensibly linking the info form the log with
> >> the tif file (or pdf file, as it will be), and mail it off to a central
> >> fax-distribution point...
> >>
> >> (does any of this make sense?!)
> >>
> >> thnx
--
"a gust of wind...a dog barks..."#! /bin/sh
# $Id: faxrcvd.sh,v 1.33 1998/02/12 10:04:57 guru Rel $
#
# HylaFAX Facsimile Software
#
# Copyright (c) 1990-1996 Sam Leffler
# Copyright (c) 1991-1996 Silicon Graphics, Inc.
# HylaFAX is a trademark of Silicon Graphics
#
# Permission to use, copy, modify, distribute, and sell this software and
# its documentation for any purpose is hereby granted without fee, provided
# that (i) the above copyright notices and this permission notice appear in
# all copies of the software and related documentation, and (ii) the names of
# Sam Leffler and Silicon Graphics may not be used in any advertising or
# publicity relating to the software without the specific, prior written
# permission of Sam Leffler and Silicon Graphics.
#
# THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
# EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
# WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
#
# IN NO EVENT SHALL SAM LEFFLER OR SILICON GRAPHICS BE LIABLE FOR
# ANY SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND,
# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
# WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF
# LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
# OF THIS SOFTWARE.
#
# 27 Dec 98, db
# edited to provide PDF delivery rather than PostScript (uses tifflib and the gs5.50
# ps2pdf utilities)
#
# faxrcvd file devID commID error-msg
#
if [ $# != 4 ]; then
echo "Usage: $0 file devID commID error-msg"
exit 1
fi
test -f etc/setup.cache || {
SPOOL=`pwd`
cat<<EOF
FATAL ERROR: $SPOOL/etc/setup.cache is missing!
The file $SPOOL/etc/setup.cache is not present. This
probably means the machine has not been setup using the faxsetup(1M)
command. Read the documentation on setting up HylaFAX before you
startup a server system.
EOF
exit 1
}
. etc/setup.cache
INFO=$SBIN/faxinfo
FAX2PS=$TIFFBIN/fax2ps
PS2PDF=$TIFFBIN/ps2pdf
TIFF2PS=$TIFFBIN/tiff2ps
TOADDR=FaxMaster
#
# There is no good portable way to find out the fully qualified
# domain name (FQDN) of the host or the TCP port for the hylafax
# service so we fudge here. Folks may want to tailor this to
# their needs; e.g. add a domain or use localhost so the loopback
# interface is used.
#
HOSTNAME=`hostname` # XXX no good way to find FQDN
PORT=4559 # XXX no good way to lookup service
FILE="$1"
BASENAME="`echo $FILE | perl -ne '($dir,$name)=split(/\//);print $name'`"
BASENAME="`echo $BASENAME | perl -ne '($name,$ext)=split(/\./);print $name'`"
TMPFILE1="tmp/"$BASENAME".ps"
TMPFILE2="tmp/"$BASENAME".pdf"
DEVICE="$2"
COMMID="$3"
MSG="$4"
if [ -f $FILE ]; then
#
# Check the sender's TSI and setup to dispatch
# facsimile received from well-known senders.
#
SENDER="`$INFO $FILE | $AWK -F: '/Sender/ { print $2 }' 2>/dev/null`"
SENDTO=
if [ -f etc/FaxDispatch ]; then
. etc/FaxDispatch # NB: FaxDispatch sets SENDTO based on $SENDER
fi
(echo "To: $TOADDR"
echo "From: HHCL Fax Agent <fax>"
echo "Subject: Facsimile received from $SENDER";
echo ""
echo "$FILE:"; $INFO -n $FILE
echo "ReceivedOn: $DEVICE"
if [ "$MSG" ]; then
echo ""
echo "The full document was not received because:"
echo ""
echo " $MSG"
echo ""
echo " ---- Transcript of session follows ----"
echo ""
if [ -f log/c$COMMID ]; then
$SED -e '/-- data/d' \
-e '/start.*timer/d' -e '/stop.*timer/d' \
log/c$COMMID
elif [ -n "$COMMID" ]; then
echo " No transcript available (CommID c$COMMID)."
else
echo " No transcript available."
fi
else
echo "CommID: c$COMMID"
fi
if [ -n "$SENDTO" ]; then
echo ""
echo "The facsimile was automatically dispatched to: $SENDTO."
fi
) | 2>&1 $SENDMAIL -ffax -oi $TOADDR
# $FAX2PS $FILE | lpr
if [ -n "$SENDTO" ]; then
$TIFF2PS -a $FILE -O $TMPFILE1 2>/dev/null
$PS2PDF $TMPFILE1 $TMPFILE2 2>/dev/null
(MIMEBOUNDARY="NextPart$$"
echo "Mime-Version: 1.0"
echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\""
echo "Content-Transfer-Encoding: 7bit"
echo "To: $SENDTO"
echo "From: HHCL Fax Agent <fax>"
echo "Subject: Facsimile received from $SENDER";
echo ""
echo "--$MIMEBOUNDARY"
echo "Content-Type: text/plain; charset=us-ascii"
echo "Content-Transfer-Encoding: 7bit"
echo ""
echo "$FILE:"; $INFO -n $FILE
echo "ReceivedOn: $DEVICE"
if [ "$MSG" ]; then
echo ""
echo "The full document was not received because:"
echo ""
echo " $MSG"
echo ""
echo " ---- Transcript of session follows ----"
echo ""
if [ -f log/c$COMMID ]; then
$SED -e '/-- data/d' \
-e '/start.*timer/d' -e '/stop.*timer/d' \
log/c$COMMID
elif [ -n "$COMMID" ]; then
echo " No transcript available (CommID c$COMMID)."
else
echo " No transcript available."
fi
else
echo "CommID: c$COMMID"
fi
echo ""
echo "--$MIMEBOUNDARY"
echo "Content-Type: application/pdf; name=\"$BASENAME.pdf\""
echo "Content-Description: FAX document"
echo "Content-Transfer-Encoding: Base64"
echo ""
/usr/bin/mimencode $TMPFILE2
echo ""
echo "--$MIMEBOUNDARY--"
) | 2>&1 $SENDMAIL -ffax -oi $SENDTO
rm -f $TMPFILE1
rm -f $TMPFILE2
fi
else
#
# Generate notification mail for a failed attempt.
#
(echo "To: $TOADDR"
echo "From: HHCL Fax Agent <fax>"
echo "Subject: facsimile not received"
echo ""
echo "An attempt to receive facsimile on $DEVICE failed because:"
echo ""
echo " $MSG"
echo ""
echo " ---- Transcript of session follows ----"
echo ""
if [ -f log/c$COMMID ]; then
$SED -e '/-- data/d' \
-e '/start.*timer/d' -e '/stop.*timer/d' \
log/c$COMMID
elif [ -n "$COMMID" ]; then
echo " No transcript available (CommID c$COMMID)."
else
echo " No transcript available."
fi
) | 2>&1 $SENDMAIL -ffax -oi $TOADDR
fi