linux-l: mgetty / new_fax / neues Fax als GIF mail attachement

Philipp Schmidt philipp at ppc.in-berlin.de
Di Okt 9 12:27:54 CEST 2001


On Tue, 2001-10-09 11:50:46 +0200, Alexander Saupe <alexsaupe at yahoo.de>
wrote in message <20011009095046.53533.qmail at web13507.mail.yahoo.com>:
> Hallo Liste,
> 
> Ziel: neu eingetroffene Faxe als Attachement per E
> Mail erhalten. Das script new_fax muss dazu umgeändert
> werden. 
> vorhandener Server: Suse 6.2, Pentium 133, 256 MB Ram
> als Mail- und Faxserver, läuft alles einwandfrei.
> 
> Frage:
> Langt die Hardware um aus dem g3 Format ein GIF oder
> PDF zu erzeugen?
> Wo finde ich ein entsprechendes new_fax Script?

mal sehen, hier sii meins (zum anpassen)
das Teil erzeugt png und druckt nochmal

#!/bin/sh
#
# /usr/local/lib/mgetty+sendfax/new_fax
#
# new_fax <getty-exit-code> <fax-sender-id> <number-of-pages> <page> [<page>..]
#
# This program is called by mgetty, when a fax is received. It sends
# the fax as a multipart/mixed MIME mail to the faxadmin ($ADMIN),
# where every fax page is attached as image/x-fax-g3 (the native
# received format, which is compact and which can be viewed with the
# viewfax command). To view and print a page from your mail reader add
# the following to your ~/.mailcap:
# image/x-fax-g3; viewfax -geometry +5+23 '%s'; test=test -n "$DISPLAY"
# image/x-fax-g3;; print=printfax '%s'
#
# You need the program mmencode for base64 encoding of the fax data,
# which you will find in your metamail distribution.
#
# (c) 1997-1998 Roland Rosenfeld <roland at spinnaker.rhein.de>
#     1999-2001 Philipp Schmidt <philipp at ppc.in-berlin.de> (modyfied)
#
# $Id: new_fax.mime3,v 1.2 2001/10/09 12:10:08 gert Exp $
#

PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin

printer="stcolor"
ADMIN="faxadmin at localhost"	# mail address of fax administrator
			# change this to your needs!

CODE="$1"		# getty exit code 
SENDER="$2"		# fax senders ID
PAGES="$3"		# number of pages
shift 3

TMP=/tmp		# temporary directory. change this to your needs.

TMPMAIL=$TMP/new_fax.$$
trap "rm -f $TMPMAIL; exit" 0 1 2 15

BOUNDARY="newfax-`date +%s`-$$"

# Create mail header:
echo "From: Fax Subsystem <$ADMIN>" > $TMPMAIL
echo "Subject: FAX from $SENDER with $PAGES pages" >> $TMPMAIL
echo "Mime-Version: 1.0" >> $TMPMAIL
echo "Content-Type: multipart/mixed; boundary=$BOUNDARY" >> $TMPMAIL
echo "" >> $TMPMAIL

# Create first part of the mail (describing the fax):
echo "--$BOUNDARY" >> $TMPMAIL
echo "Content-Type: text/plain; charset=us-ascii" >> $TMPMAIL
echo "" >> $TMPMAIL
echo "A fax from $SENDER was received at about" >> $TMPMAIL
echo "`date` consisting of $PAGES pages." >> $TMPMAIL
echo "The termination code of the fax program was $CODE." >> $TMPMAIL
echo "The pages are included below." >> $TMPMAIL
echo "" >> $TMPMAIL
echo "   Your Fax-Subsystem" >> $TMPMAIL
echo "" >> $TMPMAIL

# Add every page of the fax to the mail:
for file
do
    echo "--$BOUNDARY" >> $TMPMAIL
    echo "Content-Type: image/png" >> $TMPMAIL
    echo "Content-Transfer-Encoding: base64" >> $TMPMAIL
    echo "Content-Disposition: attachment; filename=\"`basename $file`\.png" \
                                                        	 >> $TMPMAIL
    echo "" >> $TMPMAIL

    export $file
    # print & mail it:
    if expr "`basename $file`" : "FAXn" >/dev/null
    then
        # normal resolution
	( g32pbm -s $file | /usr/bin/convert pbm\:- ps\:- | lpr -P$printer ; true) &
        g32pbm -s $file | /usr/bin/convert pbm\:- png\:- \
	                | mmencode -b >> $TMPMAIL
    else
	# fine resolution
        ( g32pbm $file | /usr/bin/convert pbm\:- ps\:- | lpr -P$printer ; true) &	
        g32pbm $file | /usr/bin/convert pbm\:- png\:- \
	             | mmencode -b >> $TMPMAIL
    fi

    echo "" >> $TMPMAIL

done

echo "--$BOUNDARY--" >> $TMPMAIL

# Send out the created mail:
sendmail -f "$ADMIN" "$ADMIN" < $TMPMAIL



exit 0

#eof

AVE!
  phils...

-- 
     PHILIPP SCHMIDT / phils - - + - - > philipp at ppc.in-berlin.de
                                 ` - - > http://home.pages.de/~phils/
     --> ONLINE fuer Berlin & BRB? IN-Berlin! (info at in-berlin.de) <--

Lbh unir whfg ivbyngrq gur Qvtvgny Zvyraavhz Pbclevtug Npg ol oernxvat gur
cebgrpgvba bs pbclevtugrq zngrevny.  Vs lbh ner abg n pvgvmra be erfvqrag bs
gur HFN, lbh evfx orvat vzcevfbarq naq uryq jvgubhg onvy sbe hc gb gjb jrrxf
hcba ragel gb gur HFN (c) Copyright 2001 by Hartmann Schaffer (signature only)



Mehr Informationen über die Mailingliste linux-l