Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
From: Ernest LaBonte <labonte!@!zk3.dec.com>
To: bob.findlay@bbsrc.ac.uk
Subject: Re: filtering jobs sent to a remote machine
Date: 1998/04/09	[thread overview]
Message-ID: <6giga1$u3$1@lead.zk3.dec.com> (raw)
In-Reply-To: 3528F993.8DB6579C@bbsrc.ac.uk

[-- Attachment #1: Type: text/plain, Size: 359 bytes --]

bob.findlay@bbsrc.ac.uk wrote:
> 
> Hello,
> I want to be able to filter a printer's jobs.  The problem is, that I
> want to filter on machine A (OSF), but the queue is actually on machine
> B (NT).  Does anyone know how I can fool printcap into filtering the job
> and then passing it on to the NT machine?  I'm using lpr
> 
> thanks (in hope)
> Bob Findlay

[-- Attachment #2: t.txt --]
[-- Type: text/plain, Size: 4099 bytes --]

Bob,

You stated the printer is on an NT machine but I will mention this anyway.
If the printer has a network card and you are running V4.0a or later
I suggest using tcp/ip printing and print to the printer directly. That
way you get to use print filters with no special modifications.

Ok, now for remote printing filtering.

There are a few ways to do this but non straight forward. The easiest way
is to preprocess the file before submitting it to the queue.  For example,
people who want to convert text to postscript would enter:

   cat file.txt | /usr/lbin/ln03rof | lpr -Premotequeue

or to get postscript landscape (2 examples depending on the version)

   cat file.txt | /usr/lbin/ln03rof -Ow132 | lpr -Premotequeue
   cat file.txt | /usr/lbin/ln03rof -Olandscape | lpr -Premotequeue

This method doesn't work well for multiple files. The script below will
help in this area. The script defaults to /usr/lbin/ln03rof. You can
specify an alternate filter at the command line, or edit the script to
default to another filter.

Hope this helps,
Ernest
---------------
#!/bin/ksh

# lprcat 19-May-1996
#
# General purpose script to preprocess a file prior to printing. Useful when
# printing to a remote queue or to a network printer using lpd remote 
# communication.
#
# The default is to convert text to postscript using the /usr/lbin/ln03rof
# filter but any filter can be specified/utilized.
#
# Usage: script [-ffilter] [options] file file ...
#
# 	[filter]  - use an alternate filter located in /usr/lbin. 
#	[options] - options that would be specified in a lpr command line.
#	file      - the file or files to print
#
# 	eg: script -Pxxx -w50 -Olandscape file file
#	    script -flpf -Pxxx -x -h file file
#

# Function: 	fcat
#
# Description:	Cat one or more files through a print filter
#
# Arguments:	$1 	- filter to use
#		$2 	- optional filter arguments
#		$3-$*	- additional filenames
#

function fcat {

	filter=$1		# Save the filter name
	shift

	cmd=$1			# Optional filter arguments
	shift

	while [[ -n $1 ]]	# Cat each filename provided through the filter
	do
		eval /bin/cat $1 | $filter $cmd
		shift
	done
}


# Function: 	fverify
#
# Description:	Verify all the files exist. 
#
# Arguments:	$*	- List of filenames to list
#

function fverify {

	while [[ -n $1 ]]
	do
		if [[ ! -f $1 ]]
		then
			print "ERROR: Unable to print file $1."
			exit 1
		fi
		shift
	done
}

# Initialize variables

filter="/usr/lbin/ln03rof"
cmd=""
queue=""
xf=""
sh=""

#
#			Code starts here
#

# Parse out filter options and lpr options
# Of course it's up to the filter to decide if the option will be used.

while getopts :f:P:z:w:i:O:K:I:o:l:xhs opt
do
	case $opt in
	P)	queue="-P$OPTARG "	# Queue name
		;;
	h)	sh="-h "		# Suppress banner page
		;;
	x)	xf="-x "		# Use xf filter
		;;
	f)	filter="/usr/lbin/$OPTARG" # Specify alternate filter
		;;
	i)	cmd="$cmd -i$OPTARG"	# Indent
		;;
	l)	cmd="$cmd -l$OPTARG"	# Page length. Filter option.
		;;
	o)	cmd="$cmd -o$OPTARG"	# Output tray
		;;
	s)	print "ERROR: Symbolic link option -s not allowed!"
		exit 1
		;;
	w)	cmd="$cmd -w$OPTARG"	# Page width
		;;
	z)	cmd="$cmd -l$OPTARG"	# Page length if lpr did support it.
		;;
	I)	cmd="$cmd -I$OPTARG"	# Input tray
		;;
	O)	cmd="$cmd -O$OPTARG"	# Orientation
		;;
	\?)	print "ERROR: Unknown option $OPTARG."
		exit 1
		;;
	:)	print "ERROR: Option $OPTARG requires a parameter."
		exit 1
	esac
done

# Now remove all the options and (hopefully) leave only file names
shift $OPTIND-1

# Check to see if the print filter exists 
[[ ! -a $filter ]] && print "ERROR: Print filter $filter not found!" && exit 1

# If no filenames print a message and get out
[[ -z $* ]] && print "ERROR: Missing filename argument!" && exit 1

# Check to see if all the files specified exist
fverify $*

# The way the command option string is created the first two characters are
# <space>- so if a command string exists remove the leading space
[[ -n $cmd ]] && cmd=$(print "$cmd" | /bin/cut -c2- )

# Now run each file through the filter and pipe the results to lpr
fcat "$filter" "$cmd" $*  | /bin/lpr $queue$sh$x

      parent reply	other threads:[~1998-04-09  4:00 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-04-06  4:00 filtering jobs sent to a remote machine bob.findlay
1998-04-06  4:00 ` James Hebert
1998-04-07  4:00 ` Jacob Langford
1998-04-08  4:00 ` Emmanuel Choquet
1998-04-09  4:00 ` Ernest LaBonte [this message]
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox