I just fixed the script, thought someone might be interested in the
result. This has been tested and works. First I created a printcap
entry like this:
/etc/printcap.local
---- begin ----
lp15:\
:ml#0:\
:mx#0:\
:sd=/var/spool/lpd/lp15:\
:af:\
:sh:\
:lp=/dev/null:\
:lpd_bounce=true:\
:if=/var/spool/lpd/lp15/filter:
---- end ----
The filter looks like this:
---- begin ----
#!/bin/bash
# Capture the spool file
#
SPOOLDIR=/tmp
cat - >$SPOOLDIR/print.$$
#Declare variables
# path to temporary files
# FILE_PDF=$SPOOLDIR/print$$.pdf
FILE_PRINT=$SPOOLDIR/print.$$
# FILE_PS=$SPOOLDIR/ps.$$
[EMAIL PROTECTED]
[EMAIL PROTECTED]
# Path to email server program
SENDMAIL="/usr/sbin/sendmail.postfix"
MIMENCODE="/usr/bin/mimencode -p"
MIMEBOUNDARY="_9pwzunTefniim1aglKe_eeki"
(
echo "To: $EMAIL_TO";
echo "From: $EMAIL_FROM";
echo "Subject: Outgoing Invoice print job";
echo "Reply-To: \"Neil Schneider\" <[EMAIL PROTECTED]>"
echo "User-Agent: lprtomail 0.1b";
echo "Mime-Version: 1.0";
echo "Content-Type: multipart/mixed;boundary=$MIMEBOUNDARY";
echo "";
echo "";
echo "--$MIMEBOUNDARY"
echo "Content-Type: text/plain; charset="iso-8859-1""
echo "Content-Transfer-Encoding: 8bit";
echo "";
echo "";
echo "This email contains an attachment which you can print on
your local printer";
echo "";
echo "";
echo "--$MIMEBOUNDARY"
echo "Content-Type: text/plain; name=\"Delivery Invoice\"";
echo "Content-Transfer-Encoding: 8bit";
echo "Content-Disposition: \"Delivery Invoice\"";
cat $FILE_PRINT
echo "";
echo "";
rm -f $FILE_PRINT
) | 2>&1 $SENDMAIL -oi $EMAIL_TO
---- end ----
Now for anyone to mail a report or other printjob from the
application, they simply choose lp15 as the printer, and it goes out
in email.
I also have another script that sends the file as a fax using hylafax.
--
Neil Schneider pacneil_at_linuxgeek_dot_net
http://www.paccomp.com
Key fingerprint = 67F0 E493 FCC0 0A8C 769B 8209 32D7 1DB1 8460 C47D
Secrecy, being an instrument of conspiracy, ought never to be the
system of a regular government.
- Jeremy Bentham, jurist and philosopher (1748-1832)
--
[email protected]
http://www.kernel-panic.org/cgi-bin/mailman/listinfo/kplug-lpsg