Operating System - HP-UX
1833847 Members
1916 Online
110063 Solutions
New Discussion

Captured spoolfiles and stripping printer escape codes from captured spoolfiles.

 
stuart campbell_2
New Member

Captured spoolfiles and stripping printer escape codes from captured spoolfiles.

Could somebody advise me on the best way to strip spoolfiles of any printer escape code.
My aim is to be left with just 'clean' text which may be upload from the HP3000 and viewed by something like notepad without garbage.

All suggetions are welcome.
3 REPLIES 3
Bill Hassell
Honored Contributor

Re: Captured spoolfiles and stripping printer escape codes from captured spoolfiles.

Unfortunately, you would have to write the entire printer's interpreter. In other words, you have to see the escape (easy) then the next character is the major category of the feature. Some are single characters (they're easy) but some are long graphic sequences or huge font files that must be removed from the data file.

The best way to strip these files is to create them without the special codes. If the source of the spool file is from a PC, pick a really simple printer so the special codes are minimized.


Bill Hassell, sysadmin
Steven Sim Kok Leong
Honored Contributor

Re: Captured spoolfiles and stripping printer escape codes from captured spoolfiles.

Hi,

Since all printing goes through the lp command, you can perform the following:
=============================================
# mv /usr/bin/lp /usr/bin/lp.bin
# cat >> /usr/bin/lp
#!/sbin/sh

for file in $*
do
case $file in
'-*') # ignore options;;
*) rcp $file userid@hp3000-server:/spooltexts/$file # replace appropriately. For security reasons you may wish to use scp instead of rcp
esac
done

/usr/bin/lp.bin $*
=============================================

Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com
Steven Sim Kok Leong
Honored Contributor

Re: Captured spoolfiles and stripping printer escape codes from captured spoolfiles.

Hi,

To elaborate with more clarity, /usr/bin/lp becomes a script. "cat >> /usr/bin/lp" requires "ctrl-d" to be pressed after all the text in the script has been entered. Remember to "chmod ugo+rx /usr/bin/lp" after the /usr/bin/lp script has been created.

To be precise, replace the entire case statement (closing with esac) within the "for loop" with:
========================================
if echo $file|grep '-' >/dev/null 2>/dev/null
then
:
else
rcp $file userid@hp3000-server:/spooltexts/$file
fi
========================================
Hope this helps. Regards.

Steven Sim Kok Leong
Brainbench MVP for Unix Admin
http://www.brainbench.com