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

Alexander Saupe alexsaupe at yahoo.de
Di Okt 9 17:18:33 CEST 2001


Danke an euch alle für die Hilfe! Mir gefällt das
Script hier auch ganz gut, nur das Drucken wird nicht
benötigt. Weiß jemand wie genau das Script umgeändert
werden muss (ab # print & mail it: müssen wohl ein
paar Sachen gelöscht werden...)?

#!/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


__________________________________________________________________
Do You Yahoo!?
Es ist soweit: das Nokia Game beginnt. Sei bereit für das multimediale Abenteuer. Melde dich bis zum 3. November bei http://de.promotions.yahoo.com/info/nokiagame.html an!



Mehr Informationen über die Mailingliste linux-l