MAL - Memória Auxiliar do Lutieri

quinta-feira, setembro 17, 2009

Hylafax - Cups Backend

#!/bin/sh
# constants
SENDMAIL="/usr/sbin/sendmail"
PS2ASCII="/usr/bin/ps2ascii"
AWK="/bin/awk"
SENDFAX="/usr/bin/sendfax"

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

##echo $6 >> /tmp/sambafax.log
##echo "fui executado as " `date` >> /tmp/sambafax.log

# now dump the to-be faxewd data (PS fdormat) to the temp file
cat $6 >${FAXFILE}

# retrieve the faxnumber from the printfile
# the silly three x's are added because some awk strugle with an immediate CR
# we use a PS to ascii pipe to strip (most of) the Postscript controls
FAXNUM=`${PS2ASCII} ${FAXFILE} | ${AWK} '{ IGNORECASE=1 } /FAX-Nr ?: ?[0-9-]*/ \
{ $0=$0 "xxx"; \
gsub(/-/,""); \
anfang=match($0,/ ?: ?/); \
anfang=anfang+match(substr($0,anfang),/[0-9]/)-1; \
ende=match(substr($0,anfang),/[^0-9]/)-1; \
printf ("%s",substr($0,anfang,ende)) \
}' `

# if faxnumber is found fax the tempfile
# we donot check the validity of the faxnumber, let sendfax do this...
if [ -z ${FAXNUM} ] ; then
##echo "Fax Number not found" >> /tmp/sambafax.log
exit 1
else
${SENDFAX} -n -d ${FAXNUM} ${FAXFILE}
## echo "status: " `echo $?` >> /tmp/sambafax.log
## echo "enviou" >> /tmp/sambafax.log
fi

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

# end of show



This is the original file used with lp, instead of cups:
http://www.hylafax.org/content/Sambafax

Marcadores: ,

0 Comentários:

Postar um comentário

<< Home



Chat with Lutieri G. B.

Subscribe in a reader