Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Apr 2005 02:14:13 +0200
From:      Gert Cuykens <gert.cuykens@gmail.com>
To:        John Conover <conover@rahul.net>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: fax4CUPS
Message-ID:  <ef60af090504121714118a9209@mail.gmail.com>
In-Reply-To: <20050410204701.2969.qmail@rahul.net>
References:  <ef60af090504101121547f510e@mail.gmail.com> <4259856C.5040604@makeworld.com> <ef60af0905041013175125dd36@mail.gmail.com> <20050410204701.2969.qmail@rahul.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On 4/10/05, John Conover <conover@rahul.net> wrote:
> Gert Cuykens writes:
> > On Apr 10, 2005 9:58 PM, Chris <racerx@makeworld.com> wrote:
> > > Gert Cuykens wrote:
> > > > Can we have this in ports ?
> > > >
> > > > http://vigna.dsi.unimi.it/fax4CUPS/
> > >
> > > Are you volunteering?
> > >
> > > Anything is possible, but nothing is easy.
> > >
> >
> > How do you mean ?
> >
> > I did not install it yet but it sounds useful if cups could handle a
> > serial fax like a printer :)
> >
> > Aldo i think the script can only send faxes and not handle incoming
> > faxes like printing them or sending them to a mailbox directory. But i
> > am sure you can add some magic faxing features to it :)
> >
> > 10$ its going to be a popular port and for people like you not that
> > hart to add some fax incomming features :) With a little bit of luck
> > you don't have to compile anything :)
>=20
> It does work well, (as per the sparse docs in the tar file.) You can
> use efax for incoming faxes, (or better, hylafax, if you can talk
> root@heaven.org into coming down and configuring it for you,) and the
> fax4CUPS does appear as a printer according to lpstat -a, and does
> send faxes, (saved as a postscript file out of openoffice.org, etc.)
> You will have to use cup's lpr -j option to tell it the "fax printer"
> what number to send the fax to, (so you will probably have to
> configure a printer in everyone's openoffice.org, etc.)
>=20
> The lpadmin command to install the cups/efax printer is:
>=20
>    lpadmin -p efax -L machine -D fax -E -v efax:/dev/ttyXX -m efax.ppd
>=20
> Where efax.ppd is installed in probably /usr/share/cups/model/, and
> the efax script, (with the first 8 lines modified for your
> configuration,) installed in probably /usr/lib/cups/backend/.
>=20
> Note: if "efax answer" is running on /dev/ttyXX from /etc/inittab, it
> may be necessary to disable "efax answer" for the lpadmin command, but
> only to install the "fax printer," (apparently, lpadmin doesn't like
> other things listening on its serial printer ports when it installs
> the printer.)
>=20
> If you use efax or hylafax for incoming, enable MIME e-mailing of the
> fax to a faxmaster, who distributes the file to the appropriate
> machine-its default for hylafax. For efax, configure /etc/efax.rc and
> /usr/bin/fax, (these are some script changes,) to send the fax
> attachment as a postscript file so they can be read with
> gv/ghostscript, (which probably came with your cups installation.) The
> efax/tiff file formats come out half size if a low resolution fax is
> received, which is corrected if postscript is used.
>=20
> Recommendation: YMMV, but hylafax is a bit difficult to configure, but
> is very robust once running; efax is probably preferable for
> non-industrial strength applications.
>=20

 mgetty-fax:/dev/cuaa0 doesnt work :( I read the install and the
manual. I can select the mgetty-fax ppd but i can not select the
mgetty-fax backend... This is the backend file.

#!/bin/bash

PAGE=3Da4
FAXPRG=3D/usr/bin/faxspool
LOGDIR=3D/var/log/mgetty

#
# This is fax4CUPS 1.24, a fax back-end for CUPS
#
# Copyright (C) 2001-2003 Sebastiano Vigna <vigna@acm.org>
#
#   This program is free software; you can redistribute it and/or modify it
#   under the terms of the GNU General Public License as published by the F=
ree
#   Software Foundation; either version 2 of the License, or (at your optio=
n)
#   any later version.
#
#   This program is distributed in the hope that it will be useful, but
#   WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABIL=
ITY
#   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public Licens=
e
#   for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, U=
SA.
#
# Modified by Michael Goffioul <goffioul@imec.be>
#
#   - phone number as option instead of job name: "-o phone=3D<number>"
#
# Additional fixes by Kevin Ivory <Ivory@SerNet.de>
#
# Additional mgetty-fax support by Daniel Glanzmann <dg@ezcom.de>
#
# Modified by Daniel Glanzmann <dg@ezcom.de>
#
#   - take care of mgetty-fax return values
#   - small cleanup
#
# Additional capisuite support by Daniel Glanzmann <dg@ezcom.de>
#

# Called with no arguments, we list the serial devices as possible fax devi=
ces.
# If /dev/modem has been set up, we list it too.

if [ $# -eq 0 ]; then
        if [ ! -x "$FAXPRG" ]; then exit 0; fi
        if [ -e /dev/modem ]; then echo "serial mgetty-fax:/dev/modem
\"Unknown\" \"Faxmodem (mgetty-fax on /dev/modem)\""; fi
        if [ -e /dev/tty.modem ]; then echo "serial
mgetty-fax:/dev/tty.modem \"Unknown\" \"Faxmodem (mgetty-fax on
/tty.modem)\""; fi
        if [ -e /dev/cu.modem ]; then echo "serial
mgetty-fax:/dev/cu.modem \"Unknown\" \"Faxmodem (mgetty-fax on
/cu.modem)\""; fi
        for ser in $(\ls -1 /dev/ttyS[0-9]* | sort -g +0.9 | head -32); do
                echo "serial mgetty-fax:$ser \"Unknown\" \"Faxmodem on
Serial Port #$((${ser#/dev/ttyS}+1)) (mgetty-fax)\""
        done
        exit 0
fi

# Get the user that owns the job
USER=3D$2
FROM=3D$USER

DEV=3D${DEVICE_URI#mgetty-fax:/dev/}
RES=3D""          # Default resolution is high; set this to -l for low reso=
lution
NUMBER=3D""       # Use option "phone" as number by default


# If we find six arguments, the last one is the fax name; otherwise,
# we have to create a temporary file.

if [ $# -eq 6 ]; then
        FAXNAME=3D$6
else
        FAXNAME=3D$(mktemp </dev/null /tmp/fax.XXXXXX) || (echo "Failed
to create temporary file" >>$LOGDIR/$DEV; exit 1)
        cat >$FAXNAME
fi

# Parse user-specified options from the PostScript file and set -l/-m
function getSelectedOption() {
        for i in $@; do
                case $i in
                        \**) SELOPT=3D${i#[*]}; return ;;
                esac
        done
}

function parseOptions() {

        while read LINE; do
                MAIN=3D${LINE%%:*}
                OPTIONS=3D${LINE##*:}
                getSelectedOption $OPTIONS

                case $MAIN in
                        PageSize/*) echo "PAGE=3D$( echo -n "$SELOPT" |
tr '[:upper:]' '[:lower:]' )" ;;
                        Resolution/*) if [ "$SELOPT" =3D=3D "204x98dpi" ];
then echo "RES=3D-l"; fi ;;
                        Dial/*) if [ "$SELOPT" =3D=3D "Manually" ]; then
echo "NUMBER=3D-m"; elif [ $SELOPT =3D=3D "JobName" ]; then echo
"NUMBER=3D-j"; fi ;;
                esac
        done
}

eval $(lpoptions -p $PRINTER -l | parseOptions)
if [ "$NUMBER" =3D=3D "-j" ]; then
         NUMBER=3D"$3";
fi

# Scan user options and set -l/-m (override previous choices if necessary)

for opt in $5; do
        case "$opt" in
                lowres*) RES=3D"-n" ;;
                hires*) RES=3D"" ;;
                manual*) NUMBER=3D"-m" ;;
                jobname*) NUMBER=3D"$3" ;;
                phone=3D*) NUMBER=3D"${opt#phone=3D}" ;;
                media=3D*) PAGE=3D$( echo ${opt#media=3D} | tr '[:upper:]'
'[:lower:]' ) ;;
        esac
done

echo 1>&2 # Apparently the first character emitted is somehow "eaten"
by the reader

# do some cheking before continuing
if [ -z "$NUMBER" ]; then
        echo "ERROR: Empty phone number" 1>&2
        exit 1
elif [ ! -x "$FAXPRG" ]; then
        echo "ERROR: $FAXPRG: executable not found" 1>&2
        exit 1
fi

pushd $LOGDIR # If there are problem, mgetty-fax will generate a log
file in the current directory

# Remove possible whitespace in number: replace by period
NUMBER=3D${NUMBER// /.}

sudo -u $USER $FAXPRG $RES $NUMBER $FAXNAME 2>>$LOGDIR/$DEV.log

RC=3D$?

case $RC in
        0) echo "INFO: Fax sent" 1>&2 ;;
        1) echo "ERROR: Cannot determine user id or unknown option" 1>&2 ;;
        2) echo "ERROR: Invalid parameters" 1>&2 ;;
        3) echo "ERROR: Phone number missing or not authorized to use
-u" 1>&2 ;;
        4) echo "ERROR: Non-numeric characters in phone number" 1>&2 ;;
        5) echo "ERROR: Cannot open File" 1>&2 ;;
        6) echo "ERROR: Cannot create new job/work directory" 1>&2 ;;
        7) echo "ERROR: Cannot determine file format" 1>&2 ;;
        8) echo "ERROR: No internal filter for format" 1>&2 ;;
        52) echo "ERROR: Nothing to do" 1>&2 ;;
esac

popd

rm -f $FAXNAME.[0-9][0-9][0-9]
if [ $# -lt 6 ]; then rm -f $FAXNAME; fi

exit $RC



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ef60af090504121714118a9209>