SUMMARY: Creating lpr input filter

From: Ashish Desai (
Date: Sat Apr 18 1992 - 23:41:36 CDT

Sorry for posting the summary this late, here it is anyway:-

>Problem: Right now we have a shell script that created a header that is
>prefixed to a file before it is printed. That is, stick a header
>to the file and then do an lpr fname.
>I would like put the filter as a "printcap entry" input filter, which
>gets invoked when the file is printed using "lpr".
>I know that you can specify an input
>filter for a printer in the "printcap".
>The problem is I can't find documentation on how to write a filter
>such that "lpr" invokes it.
>System: SUN SPARCSTATION 1 and 1+.
>OS: 4.1.1

>Can anybody send me some suggestions.


A trivial example of what you want to do:

#!/bin/csh -f
cat /full/path/to/prefixfile


There is some info in the Anserbook Rel 1 Issue 3

  System and Network Administration ( Book )
    12. Maintaining Printers and Print Servers ( Chapter )
      12.5 Output Filters ( Section )
        Output Filter Specifications ( Subsection )

>From mills@ccu.UManitoba.CA

This was described in the Sys & Net Admin manual for 4.1, but was
omitted for 4.1.1. Here is a shell script we used for an if= filter.
It illustrates the calling conventions.

# if filter for lpr
# filter [-c] -wwidth -llength -iindent -n login -h host acc_file
# files: 0 --> input data 1 --> printer 2 --> lf file
# return: 0: okay 1: reprint 2: discard

Z=`basename $0`
# parse options
for i in $*
        arg=`expr $1 : '..\(.*\)'`
        case $1 in
        -c) shift ;;
        -w*) form=$arg; shift;;
        -l*) length=$arg; shift;;
        -i*) indent=$arg; shift;;
        -n) shift; login=$1; shift;;
        -h) shift; host=$1; shift;;
        *) acc=$1;;

echo '\033%-12345X@PJL ENTER LANGUAGE=PostScript'
echo '\033%-12345X\c'

exit 0


Thanks to:


This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:41 CDT