System V printing filter

First, please excuse my apparent lack of attempt as this is NOT the case. I have attempted to research this for hours and realize I am way out of my league. I am not a programmer, especially in Unix.

I have an old Alpha Unix system with a program that prints to a network printer using the LPR command. Since no one has access to the source code or compiler anymore, re-writing the program seems out of the question. I believe what I am looking for is an if script that takes the standard text being sent to the printer, determines if it should actually print, and prints to the printer or prints to NULL.

In more explanation, the program prints all standard text. 3/4+ of this text is operational codes that mean nothing to anyone here and therefore really do not need printed. The rest of the text is needed and should be printed. All of this text needing printed ALWAYS starts of with the first line exactly equal to " Manual Base Iron Staging Moves " followed by several lines of important information. You may be able to use just the word Manual as the compare word. If the first word is NOT Manual, then the entire print job can be sent to NULL. If it is, then it should be directed to the printer.

AKA:
if print job starts with Manual
then print entire job to printer @icsp1/9100: as defined below
else send print job to Null

Printcap file entry is:

lp1|1|p1|P1|ctllpr|print1:\
	:af=/usr/adm/lp1acct:\
	:br#9600:\
	:ct=tcp:\
	:fc#0177777:\
	:fs#03:\
	:lf=/usr/adm/lp1err:\
	:lp=@icsp1/9100:\
	:mx#0:\
	:pl#66:\
	:pw#80:\
	:rw:\
	:sd=/usr/spool/lpd1:\
	:sf:\
	:sh:\
	:xc#0177777:\
	:xf=/usr/lbin/xf:\
	:xs#044000:\
	:of=/usr/lbin/pcfof +Cgeneric_text.pcf:\
	:if=/usr/lbin/pcfof +Cgeneric_text.pcf:

If any other information is required, please ask.

this appears to use the lpr/lpd protocol. in this case the print file is stored in /usr/spool/lpd/destination and from there directly transferred to the device.
do you have netcat on your system or know if a binary is available.
you could stop the print service and manually edit the print file then restart the service.
do you know what unix release this is and if it is binary compatible with anything.

Hi Ken,

The "Alpha Unix" that you are working with could be one of several versions, setting up the printers and modifying the drivers is actually relatively straight forward using the admin GUI on the later versions of what I believe will be OSF.

However from memory this Unix also supported the "lpadmin" command subset, so it may be that you want to setup a class for the printer or copy the filter file - modify the copy and attach the printer to that or even create a new printer (pointing at the same remote queue).

It is now over 15 years since I worked on Alpha kit with OSF, so bear with me if I'm a little rusty - my notes are 300 miles away and were written in a notebook. If I get a chance when I'm home I'll try and dig them out.

Regards

Gull04

jgt:

  1. Do you have netcat or if binary is available? .... "netcat: Command not found." and no I do not know if any binary's are available.
  2. Could stop print service and manually edit? .... I kind of was looking for an automated process to determine what would print and what would get "dumped"
  3. Unix release and binary compatible? .... Compaq Tru64 UNIX V5.1B (Rev. 2650) and I believe it is binary compatible (it has samba) but that may not be 100% accurate

gull04:

  1. There is no GUI anywhere that I can find. It does not even seem to have xwindows. I am basically 100% CLI.
  2. Yes, lpadmin is available to me.
  3. Setup class for the printer....??? sorry, way over my head... please explain in more detail if you want me to follow
  4. Modify filter file... Yeah, that was kind of what I was hoping to do. Copy and modify current filter file with something that would block print jobs that did not start with Manual.
  5. Absolutely no worries about being a little rusty.... I have no experience at all and this is soooo ancient I had many problems finding any information at all on it. Any help you can offer or light you can shed is more than greatly appreciated.

FYI: This machine is currently being used in a production environment so any changes made need to be small and minor with little impact to the system.

I think if you add the following code:

    :filter=/mydir/filter/myfilter

at line 9 of the printcap file.

Then create a /mydir/filter/myfilter script in sh/ksh

save="N"
while read line
do
     if [ "$save" = "N" ]
     then
         m=`echo $line|cut -c1-6`
         if [ "a$m" = "aManual" ]
        then
            save="Y"
       fi
   fi
if [ "$save" = "Y" ]
then
    echo "$line"
fi
done
1 Like