From: jmd@wa4cyb.UUCP (John Dashner)
Newsgroups: comp.unix.sysv386
Subject: Re: SCO Unix : HELP WITH HP PRINTERS:
Date: 10 Nov 92 06:49:14 GMT
Organization: John Dashner & Assoc.
X-Newsreader: TIN [version 1.1 PL6]

In article <1992Nov5.182123.6204@cs.wayne.edu> mikeg@rocdec.roc.wayne.edu (Michael George) writes:
>If anyone out there is running SCO UNIX with a HP Laserjet as your
>NETWORK PRINTER, please drop me a line. I am having much trouble getting
>it to work here on my end. I believe the problem lies somewhere in the
>print filter. PLEASE HELP IF YOU CAN!!!!!!
> 
>Actualy, the hardware is all fine, and I can print to the printer except
>the output is wrong. Page Breaks aren't in the right place etc...

Unless you've had to deal with this problem, you can't possibly imagine
how frustrating it is.  Before I include a filter that works for me, let me
explain why the HP LaserJet is problematic for UNIX users - IT WAS DESIGNED
FOR DOS!!!! ;-)

Herewith follows an lp filter/interface that might resemble others
you have seen only because I probably ripped off their good ideas.
But, I have been experimenting and hacking on this for some time and
it seems to handle the cases I'm interested in:

	1. printing landscape in line printer font
	2. printing portrait with line printer font
	3. oh, yea, printing ``normally''

Usage with the lp spooling command:

	lp -o {b,[lL],[wW]} ... (remainder of options, files, etc.)
	where:
		b      = print a banner
		l or L = Landscape with line printer font
		w or W = Wide (portrait with lineprinter font)

This filter handles: a) Unix end-of-line conventions; b) proper settings
to get the ``normal'' output of ``nroff -man'' to print correctly; and
takes care of setting (or resetting) the printer back to its normal mode.
I threw this last ``feature'' in when I was sharing the printer between
a DOS and a Unix system.  It turned out that it handled the final page
eject as well - life can be neat at times. Note the line about use of
the parallel printer interface, /dev/lp and its friends, i.e., comment
out the ``stty'' line if you are using a parallel printer interface
rather than a serial line.

Uh, oh.  just reread the post.  It says ``NETWORK PRINTER'' - does
this mean that you are spooling to another machine on a TCP/IP network??
if so, then the filter should simply cat(C) (or if you prefer, cat(1) ;-)
the file thru a ``rcmd'' (damn SCO for their man pages and renaming this
command) something like

	... after all the shifting below ....
	while [ -s "$1" ] #or whatever the shell uses to test for len > 1
	do	cat $1 | rcmd <remote-sys-name> lp
		shift
	done

Now I know this won't pass options, copies etc., but that's all I got
time to think about rite now...... otherwise, if the problem is just how to
talk to the laser attached locally then use the following - in fact, use it
on the remote printer's system too!!

============================ snip here ===============================
:
#
#	LaserJet interface that's all you need
#

printer=`basename $0`
request=$1
name=$2
title=$3
copies=$4
options=$5
shift; shift; shift; shift; shift

Landscape=no
Wide=no
banner=no

for i in $options
do
	case $i in
	l|L)		Landscape=yes
			;;
	w|W)		Wide=yes
			;;
	b)		banner=yes
			;;
	*)
			;;
	esac
done

# Set up interface
# NOTE: COMMENT OUT THE FOLLOWING LINE IF YOU ARE USING /dev/lp
stty raw 19200 -parenb cs8 ixon -istrip clocal <&1 2>/dev/null

if [ "$banner" = yes ] 
then
	echo "\033E\033&l0o7.27c66F\033&k2G\c"
	
	sysid=`uname -n`

	#user = fifth field of /etc/passwd
	user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`
	banner "$name"
	[ "$user" ] && echo "User: $user\n"
	echo "Request id: $requests\n"
	echo "Printer: $printer\n"
	echo "Options: $options\n"
	date
	echo "\nMachine: $sysid\n"
fi
while [ "$copies" -gt 0 ]
do
	for file
	do
		if [ "$Landscape" = yes ]
		then
			echo "\033E\033&l1o5.45c66F\033(s16.66H\033&k2G\c"
		elif [ "$Wide" = yes ]
		then
			echo "\033E\033&l0o7.27c66F\033(s16.66H\033&k2G\c"
		else
			echo "\033E\033&l0o7.27c66F\033&k2G\c"
		fi
		cat "$file" 2>&1
		echo "\033E\c"
	done
	copies=`expr $copies - 1`
done
exit 0