Printer is winning the battle! (for now)

All,
Q: how would I add some escape codes to an interface that i have setup t print.?
Goal: to switch from NLQ to Util modes. back and forth.

Scenerio:
SCO OS 5.05
PRINTER: OKI Data 320 or similar. printer is called "test"

What I have done thus far. (just cannot get their)

I can from a #prompt

bash#echo -e "\033\170\061\033\153\0" | lp -d test

(results my printer changes to NLQ mode properly.)
any echoing from this point results in all text being NLQ mode quality...

Alternatively

bash#echo -e "\033\170\00" | lp -d test

(results my printer switches back to UTIL mode)
any echoing from this point results in all test being UTIL MODE quality

I have a pgm that uses a config file for all its output which just doesnt allow for these codes to be inserted.
In case your wondering its a BB3 pgm that uses a config.bbx file.
the current line status is

alias P6 ">lp -dtest -s 2>/dev/null" "AT PO's Fast"  CR,SP=1B4D,SPCOLS=80,CP=1B4D,CPCOLS=104,EPON=1B77011B5701,EPOFF=1B77001B5700,EPCOLS=2
,EPLINES=2,WAIT=0
alias P7 ">lp -dtest -s 2>/dev/null" "AT PO's NLQ Pls Set NLQ NOW."  PTON=1B77311B6B0,SP=1B77311B6B0,CR,SPCOLS=80,CP=,CPCOLS=104,EPON=,EPO
FF=,EPCOLS=2,EPLINES=2,WAIT=0

In the above I have tried lots of variations to toggle the NLQ/UTIL mode.. all with no luck.

So I was thinking I could modify a printer interface specifically the dumb one and make 2 printer scenerios.
DumbNLQ and DumbUTIL and then just send the desired output to the desired printer interface.

Also, I did try the

lp -o nlq -d test

and

lp -o lq -d test

my particular printer just does not respond to those options (fond in the man lp pages)

I have been trying to insert the octal codes above into a dumb interface script <below) . for my printer all with no luck.
the dumb script is below.
I have commented out some of it for banner page reasons. But where if at all possible would I add the codes to toggle the printer mode.?

*********************************** Begin dumb interface Script ***************************

:
#	@(#) dumb 25.2 95/03/27 
#
#	Copyright (C) 1988-1995 The Santa Cruz Operation, Inc.
#		All Rights Reserved.
#	The information in this file is provided for the exclusive use of
#	the licensees of The Santa Cruz Operation, Inc.  Such users have the
#	right to use, modify, and incorporate this code into other products
#	for purposes authorized by the license agreement provided they include
#	this notice and the associated copyright notice with any such product.
#	The information in this file is provided "AS IS" without warranty.
#
#ident	"@(#)lp:model/dumb	1.3.1.2"
# lp interface for dumb line printer
#

x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

#Set up some global variables.
: ${SPOOLDIR:=/usr/spool/lp}
: ${LOCALPATH:=${SPOOLDIR}/bin}

#Set up the default filter.
if [  -x "${LOCALPATH}/lp.cat" ]
then
	LPCAT="${LOCALPATH}/lp.cat 0"
else
	LPCAT="cat"
fi

#If we are not using a filter, use the default one.
if [ -z "${FILTER}" ]
then
	FILTER="${LPCAT}"
fi

if [ -x "${LOCALPATH}/drain.output" ]
then
	DRAIN="${LOCALPATH}/drain.output 1"
else
	DRAIN=
fi 

nobanner="no"

if [ -z "${BANNERS}" ]
then
	nhead=1
else
	nhead=${BANNERS}
fi

for i in $5
do
	case "${i}" in

	nobanner )
		nobanner="yes"
		;;
	esac
done


#if [ "no" = "${nobanner}" ] ;This is the stock line.  
if [ "yes" = "${nobanner}" ]
then

	while [ $nhead -gt 0 ]
	do
		#echo "\014\c"       "remed out by SR to stop extra form feed""
		echo "$x\n$x\n$x\n$x\n"
		banner "$2"
		echo "\n"
		user=`grep "^$2:" /etc/passwd | line | cut -d: -f5`
		if [ -n "$user" ]
		then
			echo "User: $user\n"
		else
			echo "\n"
		fi
		echo "Request id: $1    Printer: `basename $0`\n"
		date
		echo "\n"
		if [ -n "$3" ]
		then
			banner $3
		fi
		#nhead=`expr $nhead - 1`
		nhead=0
	done
fi

copies=$4
shift; shift; shift; shift; shift
files="$*"
i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		0<${file} eval ${FILTER} 2>&1
		#echo "\014\c"     # "Remed out by SR to stop extra from feed..."   "
	done
	i=`expr $i + 1`
done


#if [ "no" = "${nobanner}" ] ;This is the stock line   
if [ "yes" = "${nobanner}" ]
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

#Draining characters might be necessary.
${DRAIN}

exit 0

********************************** End of Script ***************************************

Thanks in advance for your time! :slight_smile:
Sam

while [ $i -le $copies ]
do
    for file in $files
    do
        echo "\033\0170\061\033\0153\0\c"
        0<${file} eval ${FILTER} 2>&1
        echo "\033e\c"   # or whatever the escape sequence is to return the printer to its power on settings
        #echo "\014\c"     # "Remed out by SR to stop extra from feed..."   "
    done
    i=`expr $i + 1`
done

If you want to be really fancy, echo the escape sequences into a file, and then add a -o file_name to the lp statement.

=1
while [ $i -le $copies ]
do
    for file in $files
    do
        0< /usr/spool/lp/bin/$5  #because of the shift statement, you should copy $5 to a variable before the shift statment
        0<${file} eval ${FILTER} 2>&1
        echo "\033e\c"   # or whatever the escape sequence is to return the printer to its power on settings
        #echo "\014\c"     # "Remed out by SR to stop extra from feed..."   "
    done
    i=`expr $i + 1`
done
copies=$4
letterquality=$5
shift; shift; shift; shift; shift
..........
         0</usr/spool/lp/bin/$letterquality
.......

1 Like

JGT,
Thanks, first off.
I swear i have tried that exact line and location....
till I saw the 0's you added?
My code echo

"\033\170\061\033\153\0\c"

your version echo

"\033\0170\061\033\0153\0\c"

How and where did you know to add that?
-Sam

Ahhh, the lp script runs as a Bourne shell, not bash.
The -e option is dropped, and the leading 0 is added to indicate that the numeric value is octal not decimal.

1 Like

I was wondering why it worked while in BASH and not in the stock shell.
I dd some tests back and forth with and without the -e...

Q: if the add 0 case is the case. as in the proof? of it works..
how come all the OCTAL's dont get a the additional 0?
just the few?

---------- Post updated at 07:58 PM ---------- Previous update was at 07:48 PM ----------

Is it as simple as any number (thats an octal) that doenst already start with a leading 0 zero, requires an additional 0 Zero? Kind of like an escape for an escape?
Because I noticed that the only ones that got the additional Zero were the ones that didn't
already start with one.. :?

If the first character is a 0 then the field is taken as octal. so "010" is 8 (decimal) the same as "0010" whereas "10" is 10 decimal, or 12 octal.. I usually code all 4 digits.

1 Like

I see! cool
Many many thanks!