Custom header pages

The root user can create custom header pages for users by modifying the definition of the sh attribute.

Because the spooler processes have access to the environment of the user that submitted the job to the spooler, the root user can modify the portion of the sh attribute definition that specifies which header page template to process.

For example, H.ascii specifies which header page template should be processed and printed. It can be replaced with a user environment variable of your choice, such as $MYHEADER, as shown below.

 %Ide          INCLUDE: (Directory Containing Miscellaneous 
Modules)
 '/pioburst '
 %F[H]         If "-H] Argument" on Command Line, "-# Argument" 
-> OUTPUT
 ' '
 %Idb          INCLUDE: (Directory Containing Header and Trailer 
Text Files)
 '/$MYHEADER | '
 %Ide          INCLUDE: (Directory Containing Miscellaneous 
Modules)
 '/pioformat -@'
 %Idd          INCLUDE: (Directory Containing Digested Data Base 
Files)
 '/'
 %Imm          INCLUDE: (File Name Of (Digested) Data Base; Init.
 By
               "piodigest" (mt.md.mn.mq:mv))
 ' -!'
 %Idf          INCLUDE: (Directory Containing Loadable Formatter 
Routines)
 '/piof5202 -L! -J! '
 %IsH          INCLUDE: (FORMATTING FLAGS for header page)
 ' -u'
 %IuH          INCLUDE: (Input PAPER TRAY for header page)

To enable the user susan to get custom header pages with this queue, the root user could use the following procedure:

  • Type cp /usr/lib/lpd/pio/burst/H.ascii /usr/lib/lpd/pio/burst/H.susan
  • Edit H.susan to Susan's taste in header pages.
  • Set the environment variable MYHEADER in Susan's environment to H.susan. (For example, in the Korn shell, use export MYHEADER=H.susan).

When the user susan submits a job to this queue, the sh attribute's reference to a header page template will resolve to /usr/lib/lpd/pio/burst/H.susan, and the user susan will receive a custom header page. The problem with this scenario is that the environment variable MYHEADER must be defined for anyone that uses the queue associated with this virtual printer; otherwise, the virtual printer cannot resolve the reference to /usr/lib/lpd/pio/burst/$MYHEADER. An error will result if $MYHEADER is undefined; the job might print, but the header page will be recyclable at best.

To avoid the problem of everyone that uses this queue having to have MYHEADER defined, you can integrate some shell code into the sh attribute definition to examine the user environment before the header page pipeline is created. One method for doing this is shown below.

Pipeline for Header Page
sh = { if test X"$MYHEADER" = X ; then %Ide/pioburst %F[H] 
%Idb/H.ascii | %Ide/pioformat -@%Idd/%Imm -!%Idf/piof5202 -L! -J!
%IsH -u%IuH; else %Ide/pioburst %F[H] %Idb/$MYHEADER |
%Ide/pioformat -@%Idd/%Imm -!%Idf/piof5202 -L! -J! %IsH -u%IuH;
fi; } 
 '{ if test X"$MYHEADER" = X ; then ' 
 %Ide          INCLUDE: (Directory Containing Miscellaneous
Modules)
 '/pioburst '  
 %F[H]         If "-H] Argument" on Command Line, "-# Argument"
-> OUTPUT
 ' '           
 %Idb          INCLUDE: (Directory Containing Header and Trailer
Text Files)
 '/H.ascii | ' 
 %Ide          INCLUDE: (Directory Containing Miscellaneous
Modules)
 '/pioformat -@' 
 %Idd          INCLUDE: (Directory Containing Digested Data Base
Files)
 '/'           
 %Imm          INCLUDE: (File Name Of (Digested) Data Base; Init.
By
               "piodigest" (mt.md.mn.mq:mv))
 ' -!'         
 %Idf          INCLUDE: (Directory Containing Loadable Formatter
Routines)
 '/piof5202 -L! -J! ' 
 %IsH          INCLUDE: (FORMATTING FLAGS for header page)
 ' -u'         
 %IuH          INCLUDE: (Input PAPER TRAY for header page)
 '; else '     
 %Ide          INCLUDE: (Directory Containing Miscellaneous
Modules)
 '/pioburst '  
 %F[H]         If "-H] Argument" on Command Line, "-# Argument"
-> OUTPUT
 ' '           
 %Idb          INCLUDE: (Directory Containing Header and Trailer
Text Files)
 '/$MYHEADER | ' 
 %Ide          INCLUDE: (Directory Containing Miscellaneous
Modules)
 '/pioformat -@' 
 %Idd          INCLUDE: (Directory Containing Digested Data Base
Files)
 '/'           
 %Imm          INCLUDE: (File Name Of (Digested) Data Base; Init.
By
               "piodigest" (mt.md.mn.mq:mv))
 ' -!'         
 %Idf          INCLUDE: (Directory Containing Loadable Formatter
Routines)
 '/piof5202 -L! -J! ' 
 %IsH          INCLUDE: (FORMATTING FLAGS for header page)
 ' -u'         
 %IuH          INCLUDE: (Input PAPER TRAY for header page)
 '; fi; } '    

The original st definition is repeated twice in the new st definition. The shell code checks to see if MYHEADER is defined; if MYHEADER is not defined, then the header page template H.ascii is used, else the header page template $MYHEADER is used.