[Samba]Samba and HylaFax

Tim Allen timallen at ls82.fsnet.co.uk
Tue Jan 29 02:01:21 GMT 2002


Sanjiv

Take a look at http://www.purpel3.com/sambafax/

The sambafax script has a few shortcomings (to do with faxnumber extraction
and failing on landscape prints) which I fixed (see updated script below).
Although I sent the sambafax guys this update, it doesn't seem to have found
it's way onto their website.We've been using this for several months to fax
reports generated by an Access application for generating enquiries and
orders. It extracts the fax number from the orders so is completely
automatic. Note the format of the embedded fax string is slightly different
to the original to increase robustness.

If you need any other info, probably best to use the Hylafax mailing list
which I'm also subscribed to, as this is rather off-topic for Samba.

Tim Allen

----- Original Message -----
From: "Sanjiv Bawa" <sbawa at tabmaster.com>
To: <samba at lists.samba.org>
Sent: Tuesday, January 29, 2002 6:17 AM
Subject: [Samba]Samba and HylaFax


> I want to integrate Samba and HylaFax functionality.
>
> Basically throw Postscript files into a samba print share and have it
faxed
> using Hyla Fax. Anyone have a little script they would like to share?
>
> Thanks.
>
>
> --
> To unsubscribe from this list go to the following URL and read the
> instructions:  http://lists.samba.org/mailman/listinfo/samba
>
>

#!/bin/sh
#
# Faxing with HylaFax through a faxprinter
#
# This script is heavily depending (just about copied) from the work of:
#     -------------------------------------------------
#     Faxfilter für MS-Windows und lpd und mgetty-paket
#     Author     : Wundrig Roland <roland at cygnus.muc.de>
#     -------------------------------------------------
# Installation.
# On top of the "normal" Hylafax installation you do the following:
# 1. Put the following lines in the /etc/printcap file and delete (if
#    applicable) any other faxprinters:
#
#    faxlp:\
#      :lp=/dev/null:\
#      :sd=/usr/spool/lpd:\
#      :if=/var/spool/hylafax/bin/sambafax:\
#      :sh:sf:mx#0:
#
#    or for lprng
#
#    faxlp:\
# :lp=/dev/null:\
# :if=/var/spool/hylafax/bin/sambafax:\
# :sd=/var/spool/lpd:\
# :sh:ff_separator:bkf:mx#0:
#
# 2. Store this file as /var/spool/hylafax/bin/sambafax or in the bin
#    directory of your hyla tree (but then adjust the path in printcap)
#
# 3. I assume that your samba configuration shows all printers
#
# 4. restart lpd and samba
#
# 5. On your samba client, install a new printer with a postscript
#    driver (like an apple laserwriter) to print to \\YOURSERVER\faxlp
#
# 6. Create a fax using your favorite wordchewer and take up a line like:
#        Fax : '012-345-6789'
#    and print to your new faxprinter
#
#
# The intellectual (c) remains with Wundrig Roland
# This rev created by ignace.suy at reeel.nl, september 2000
# and modified by Tim Allen (timallen at dcallen.co.uk), 18-July-2001
#

# constants
SENDMAIL="/usr/sbin/sendmail"

# make up a temporary file
FAXFILE=/tmp/sambafax.$$

# retrieve the username and hostname from the parameters
while :
do
    case "$1" in
        -n) Username="$2"
            shift ; shift
            ;;
        -h) Hostname="$2"
            shift ; shift
            ;;
       -*)  shift
            ;;
        *) break
    esac
done

# if the samba user is anonymous then send mails to the postmaster
if [ "$Username" = "nobody" ];
   then
    MailTo="postmaster"
   else
    MailTo=${Username}
fi

# now dump the to-be faxed data (PS format) to the temp file
cat >${FAXFILE}

# Retrieve the faxnumber from the printfile -

# Spaces and hyphens are permitted in all of the following
# FAX may be any mix of upper and lower case
# Match FAX : '01234 567890'
FAXNUM=`pstotext ${FAXFILE} | sed -n "y/fax/FAX/
/.*FAX *: *'[0-9 ][0-9 -]*[0-9 ]'/{
s/.*FAX *: *'\([0-9 ][0-9 -]*[0-9 ]\)'.*/\1/
s/[ -]*//gp
q
}"`

# If it was landscape, the above won't work. We must pass through pstotext
# again with the -landscape flag.
if [ "${FAXNUM}" = "" ] ; then
FAXNUM=`pstotext -landscape ${FAXFILE} | sed -n "y/fax/FAX/
/.*FAX *: *'[0-9 ][0-9 -]*[0-9 ]'/{
s/.*FAX *: *'\([0-9 ][0-9 -]*[0-9 ]\)'.*/\1/
s/[ -]*//gp
q
}"`
fi


# if faxnumber is found fax the tempfile
# we do not check the validity of the faxnumber, let sendfax do this...
if [ "${FAXNUM}" = "" ] ; then
    (echo "To: ${MailTo}"
     echo "From: The HylaFAX Samba print service <fax>"
     echo "Subject: Your facsimile request failed"
     echo ""
     echo -n "The faxnumber is not recognized in your fax of "
     echo -n `date`
     echo "."
     echo "The faxnumber is recognised by this text:"
     echo ""
     echo "   Fax: 'ddd-dd ddddd'"
     echo ""
     echo "Only spaces or '-' characters are allowed between the digits."
     echo ""
     echo "Please correct and retry."
    ) | 2>&1 $SENDMAIL -ffax -oi ${MailTo}
else
    sendfax -n -D -m -f ${MailTo} -d ${FAXNUM} ${FAXFILE}
fi

# remove the temp file
# rm -f ${FAXFILE}

# end of show







More information about the samba mailing list