From: carlkb@uts.uni-c.dk (Klaus Bock)
Newsgroups: comp.sys.sgi.admin
Subject: Re: Problem with HP Laserjet III
Date: 23 Dec 92 11:21:28 GMT
Organization: UNI-C, Danish Computing Centre for Research and Education

In <1992Dec16.125135.14385@news.uni-stuttgart.de> erwin@cvtserv1.verfahrenstechnik.uni-stuttgart.de (Erwin Dieterich) writes:

>Hi net-people,

>I have a problem getting a HP Laserjet III working at my parallel
>port running 4.0.1. Is there anyone out there who has written an
>interface for our Printer? And is he willing to send it to me?

>Thanks for your help and merry Xmas!

You might try to use some of the following stuff:

============= File: ihplj ===========================================
#!/bin/sh
#
# lp interface for dumb line printers, serial or parallel
#
# Configurable paramters:
#
# BANNER	If non-zero, print a 132 column banner before each job
# TRAILER	If non-zero, print a page separator with some form feeds at
#		the end of the job.
# RAW		If non-zero, don't do any post-processing like newline to
#		newline/carriage return conversion.
# STTYPARAMS	Add any non-default stty options here.
# BAUDRATE	Sets the baud rate for tty printers
#
# The BANNER, TRAILER, and RAW flags may be turned on or off for a given
# print job by using the "-o" option of the lp command.
#
# P10	Print in portrait mode with courier 10 pitch
# P16	Print in portrait mode with courier 16.66 pitch
# L10	Print in landscabe mode with courier 10 pitch
# L16	Print in landscabe mode with courier 16.66 pitch
# G	Print in graphics mode
# GD	Print in graphics mode and delete the file afterwords.
#
# The PORT10, PORT1666, LAND10, LAND1666, GRAPHICS, GRAPHICSD flags 
# may be turned on or off for a given
# print job by using the "-o" option of the lp command.
#
# Info for administration tools:
#
# NAME=HP LaserJet series II
#
NAME="HP LaserJet series II"
TYPE=Dumb

# Change the following to set up defaults
STTYPARAMS=
BAUDRATE=9600
BANNER=0
TRAILER=0
RAW=0
PORT10=1
PORT1666=0
LAND10=0
LAND1666=0
GRAPHICS=0
GRAPHICSD=0
CNT=0
MCNT=0

#
# Grab command line arguments
printer=`basename $0`
seqid=$1
name=$2
title="$3"
copies=$4
options="$5"
shift; shift; shift; shift; shift
files="$*"

#
# Parse printer-specific options specified with lp(1) -o option
#
set -- "$options"
while test $# -ne 0
do
	case $1 in
		notrailer)
			TRAILER=0
			;;
		trailer)
			TRAILER=1
			;;
		banner)
			BANNER=1
			;;
		nobanner)
			BANNER=0
			;;
		raw)
			# Don't do any post processing on this one.  This works
			# well when sending bitmaps and things to an intelligent
			# printer.
			RAW=1
			;;
		cooked)
			RAW=0
			;;
                p10)
			PORT10=1
			PORT1666=0
			LAND10=0
			LAND1666=0
			GRAPHICS=0
			GRAPHICSD=0
			;;
                p16)
			PORT10=0
			PORT1666=1
			LAND10=0
			LAND1666=0
			GRAPHICS=0
			GRAPHICSD=0
			;;
                l10)
			PORT10=0
			PORT1666=0
			LAND10=1
			LAND1666=0
			GRAPHICS=0
			GRAPHICSD=0
			;;
                l16)
			PORT10=0
			PORT1666=0
			LAND10=0
			LAND1666=1
			GRAPHICS=0
			GRAPHICSD=0
			;;
                g)
			PORT10=0
			PORT1666=0
			LAND10=0
			LAND1666=0
			GRAPHICS=1
			GRAPHICSD=0
			RAW=1
			;;
                gd)
			PORT10=0
			PORT1666=0
			LAND10=0
			LAND1666=0
			GRAPHICS=0
			GRAPHICSD=1
			RAW=1
			;;
                cnt)
			PORT10=0
			PORT1666=0
			LAND10=0
			LAND1666=0
			GRAPHICS=1
			GRAPHICSD=0
			RAW=1
			CNT=1
			;;
                mcnt)
			PORT10=0
			PORT1666=0
			LAND10=0
			LAND1666=0
			GRAPHICS=1
			GRAPHICSD=0
			RAW=1
			MCNT=1
			;;
		*)
			# Save any extra options and pass on to filter.
			if [ -n "$1" ]
			then
				opts="$opts $1"
			fi
			;;
	esac
	shift
done

#
# Initialize port parameters
#
if [ -t 1 ]
then
	stty sane $BAUDRATE <&1
	if [ "$STTYPARAMS" != "" ]
	then
		stty $STTYPARAMS <&1
	fi
	if [ $RAW != 0 ]
	then
		stty -opost <&1
	fi
	filter="cat $opts"
else
	if [ $RAW != 0 ]
	then
		filter="cat $opts"
	else
		# The plp filter supports the sane, onlcr, opost, and tab3
		# stty options.
		filter="/usr/lib/plp sane $STTYPARAMS $opts"
	fi
fi

(
# Change this for prettier banners or different number of columns
x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
if [ $BANNER != 0 ]
then
	echo "$x\n$x\n$x\n$x\n"
	banner "$name"
	echo "\n"
	user=`grep "^$name:" /etc/passwd | line | cut -d: -f5`
	if [ "$user" = "" ]
	then
		user=`(ypmatch $name passwd | line | cut -d: -f5) 2> /dev/null`
	fi
	if [ -n "$user" ]
	then
		echo "User: $user\n"
	else
		echo "\n"
	fi
	echo "Request id: $seqid    Printer: `basename $0`\n"
	date
	echo "\n"
	if [ -n "$title" ]
	then
		banner $title
	fi
	echo "\014\c"
fi

# Now setup the printer for the selected printing type

if [ $PORT10 != 0 ]
then
	echo "\033E\033&l0O\c"
fi

if [ $PORT1666 != 0 ]
then
	echo "\033E\033&l0O\033&k2S\c"
fi

if [ $LAND10 != 0 ]
then
	echo "\033E\033&l1O\c"
fi

if [ $LAND1666 != 0 ]
then
	echo "\033E\033&l1O\033&k2S\c"
fi

if [ $GRAPHICS != 0 ]
then
	echo "\033E\033&l0O\033(11U\033(sp10h12vsb3T\c"
fi

if [ $GRAPHICSD != 0 ]
then
	echo "\033E\033&l0O\033(11U\033(sp10h12vsb3T\c"
fi

i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		if [ $CNT != 0 ]
		then
			/sgi320/carlsberg/Inmrprog/cnt < $file 2>&1
		else
			if [ $MCNT != 0 ]
			then
				/sgi320/carlsberg/Inmrprog/IOmcnt < $file 2>&1
			else
				cat "$file" 2>&1
			fi
		fi
		if [ $RAW = 0 ]
		then
			echo "\033E\c"
		fi

		if [ $GRAPHICS != 0 ]
		then
			echo "\033E\c"
		fi

		if [ $GRAPHICSD != 0 ]
		then
			echo "\033E\c"
			rm $file
		fi
	done
	i=`expr $i + 1`
done

#
# Print a couple rows of XXX followed by some newlines
#
if [ $TRAILER != 0 ]
then
echo "$x\n$x\n$x\n$x\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n$x\n$x\n$x\n$x"
echo "$x\n$x\n$x\n$x\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "$x\n$x\n$x\n$x\n$x\n$x\n$x\n$x\n"
fi
) | $filter

exit 0
============= End of file ===========================================

Save the portion between the ==== lines as ihplj, and install the
printer (assuming you are using Sys V printer spooler!) by:


/usr/lib/lpshut
/usr/lib/lpadmin -pihplj -v/dev/plp -chplaser -iihplj
/usr/lib/lpadmin -dihplj
/usr/lib/accept ihplj
/usr/lib/accept hplaser
/usr/lib/lpsched
enable ihplj

Some of the "cnt" stuff you can't use, but this is just an example of
how we use the printer to print out large graphics files; instead of filling
the disks with 500 graphics print jobs (each might be 1Mb), we simply call
the program generating the graphics in the spooler script file, and then
the output will be passed directly to the printer. It is then just necessary
to submit the input to the graphics program to the queue...

To use this printer:

lp -dihplj -op10 file		!Print out file in 10 pitch portrait
lp -dihplj -ol10 file		!Print out file in 10 pitch landscape
lp -dihplj -op16 file		!Print out file in 16.67 pitch portrait
lp -dihplj -ol16 file		!Print out file in 16.67 pitch landscape
lp -dihplj -og file		!Print out graphics file

You could also implement printing in 12 pitch on the LaserJet III printer -
this was originally written for the LaserJet II.

If you want to print out PostScript, get the Ghostscript package - you
can simply set it up so that the queue script file calls the gs program and
sends the output directly to the printer. If you think that the fonts in
the GhostScript package look awful - don't panic - all the fonts you
need (Courier, Helvetica, Times-Roman) already exist on the SGI machines in
the directory /usr/lib/DPS/outline/base. Of course they cannot send out
these fonts with the GhostScript package, as they are copyrighted by
Adobe.

Good luck, merry Xmas&happy New Year from:

Mogens Kjaer
Carlsberg Laboratory, Dept. of Chemistry
Gamle Carlsberg Vej 10
DK-2500 Valby
Denmark
carlkb@uts.uni-c.dk
Xref: sparky comp.sys.sgi.admin:70 comp.sys.sgi.misc:71