A Sample Shell Script Interface

# NLQ fonts

courier=0
sansserif=1
prestige=3
boldps=6

# Justification codes

left=0
center=1
right=2
leftright=3

# Variables

nlq=no
font=$courier
progpitch=0
justify=$left
tab4=no

for i in $options
do
	case $i in
		nlq)
			nlq=yes
			;;
		font=* )
			font=`parse ${i}`
			font=`eval echo $"$font"`
			;;
		pica)
			progpitch=0
			;;
		elite)
			progpitch=`expr $progpitch + 1`
			;;
		prop)
			progpitch=`expr $progpitch + 2`
			;;
		compressed)
			progpitch=`expr $progpitch + 4`
			;;
		emph)
			progpitch=`expr $progpitch + 8`
			;;
		double)
			progpitch=`expr $progpitch + 16`
			;;
		wide)
			progpitch=`expr $progpitch + 32`
			;;
		italic)
			progpitch=`expr $progpitch + 64`
			;;
		underline)
			progpitch=`expr $progpitch + 128`
			;;
		justify=* )
			justify=`parse ${i}`
			justify=`eval echo $"$justify"`
			;;
		tab4)
			tab4=yes
			;;
	esac
done

# Reset the printer no matter what else is happening

echo "\033@\c"

# Set the Near Letter Quality mode & NLQ font style

if [ "$nlq" = yes ]
then
	echo "\033x1\c"
	echo "\033k${font}\c"
fi

# Set the programmable pitch/highlighting
#	This combines the following modes:
#	underlining, italic, double width, double print, emphasized,
#	compressed, proportional spacing, and elite/pica
# The syntax seems a bit convoluted, but the value delivered to the ESC-!
# printer command must be a binary value.  Since echo works with octal, the
# awk command simply replaces the decimal value with the octal equivalent.
# The "hard part" was getting echo to use it: echo must have that leading zero!

progpitch=`echo ${progpitch} | awk '{printf("%03o",$0)}'`
echo "\033!\\0${progpitch}\c"

# Set the justification
#	0 = Left aligned (normal)
#	1 = Centered between margins
#	2 = Right aligned
#	3 = Left/Right justified

echo "\033a${justify}\c"

# Set tab stops every 4 positions

if [ "$tab4" = yes ]
then
 echo "\033D\004\010\014\020\024\030\034\040\044\050\054\060\064\070\074\000\c"
fi

