From owner-freebsd-questions Mon Oct 6 08:16:16 1997 Return-Path: <owner-freebsd-questions> Received: (from root@localhost) by hub.freebsd.org (8.8.7/8.8.7) id IAA04136 for questions-outgoing; Mon, 6 Oct 1997 08:16:16 -0700 (PDT) (envelope-from owner-freebsd-questions) Received: from ns.co.lenoir.nc.us ([152.34.59.2]) by hub.freebsd.org (8.8.7/8.8.7) with SMTP id IAA04115 for <freebsd-questions@freebsd.org>; Mon, 6 Oct 1997 08:16:11 -0700 (PDT) (envelope-from dkite@co.lenoir.nc.us) Received: from mail.co.lenoir.nc.us (mail.co.lenoir.nc.us [152.34.59.5]) by ns.co.lenoir.nc.us (8.7.5/8.7.3) with ESMTP id LAA06264 for <freebsd-questions@freebsd.org>; Mon, 6 Oct 1997 11:24:03 GMT Message-Id: <199710061124.LAA06264@ns.co.lenoir.nc.us> Received: from FINANCE/SpoolDir by mail.co.lenoir.nc.us (Mercury 1.31); 6 Oct 97 11:44:19 -0500 Received: from SpoolDir by FINANCE (Mercury 1.31); 6 Oct 97 11:43:51 -0500 From: "Doug Kite" <dkite@co.lenoir.nc.us> To: freebsd-questions@freebsd.org Date: Mon, 6 Oct 1997 11:43:49 -0400 MIME-Version: 1.0 Content-type: text/plain; charset=US-ASCII Content-transfer-encoding: 7BIT Subject: input filter for lp Priority: normal X-mailer: Pegasus Mail for Win32 (v2.54) Sender: owner-freebsd-questions@freebsd.org X-Loop: FreeBSD.org Precedence: bulk How do I get a script I have written to act as an input filter for lpd? I have written a script in awk that checks the width of the file on standard input and sends the proper initialization sequence for the printer. The script is working fine, and I can type: ls -l | lpfilter or cat foo | lpfilter and the codes are inserted properly, but... Even though I put an entry in my printcap file that lists my script as the input filter, it does not execute when I print a file. I know the script works, and does what I want, but I can't get it to execute automatically when something is printed. Any thoughts would be appreciated. Doug Here's the /etc/printcap entry: lp|hp|hp4v|HP Laserjet 4V|\ :sd=/var/spool/lpd/hp:\ :rm=192.168.0.15:\ :rp=text:\ :lp=:\ :if=/usr/bin/lpfilter:\ :lf=/var/log/lpd-errs:\ :sh: And here is the lpfilter script: #!/usr/bin/awk -f # Add printer setup codes to first long line # \x1B - ESC (ASCII 027, HEX 1B) # &l1o5.369C - orientation landscape, vertical motion index # (s12.5H - pitch 12.5 # first part of P sets font to courier, pitch 10, symbol set PC-8 # &l0o7.183C - orientation portrait, vertical motion index # %s - the string (the original line, $0) # \n - newline BEGIN { W = 0 I = "\x1B&l1o5.369C\x1B(s12.5H" P = "\x1B(10U\x1B(s0p10h0s0b4099T\x1B&l0o7.183C" } { if (W == 0 && length > 85) { if (index($0,"\x0C") != 0) { split($0,p,"\x0C") printf("%s\x0C%s%s\n",p[1],I,p[2]) } else { printf("%s%s\n",I,$0) } W = 1 } else { { if (NR == 1) { printf("%s%s\n",P,$0) } else { print $0 } } } } __________________________________________________ Doug Kite email: dkite@co.lenoir.nc.us Network Administrator phone: 919-559-6442 Lenoir County MIS fax: 919-523-0371