Kbase P123562: How to control print jobs with more granularity on Unix?
Autor |
  Progress Software Corporation - Progress |
Acesso |
  Público |
Publicação |
  16/10/2008 |
|
Status: Unverified
GOAL:
How to control print jobs with more granularity on Unix?
GOAL:
How to access the print job number on Unix?
GOAL:
How to detect the job number of a printer output on Unix?
GOAL:
What is the position of the printing output in the print spooler on Unix?
GOAL:
How is printing from the 4GL client implemented on Unix?
GOAL:
How to control the print queue from a 4GL program on Unix?
FACT(s) (Environment):
Progress 9.x
OpenEdge 10.x
UNIX
FIX:
When a 4GL program starts to print with OUTPUT TO PRINTER on Unix, the Progress/OpenEdge client starts the command "lp" in a sub-process. Then as the data is generated by the program for the printout, the data is forwarded as a data input to the "lp" sub-process. When the program finishes printing with OUTPUT CLOSE, the input of the "lp" sub-process is closed.
This mechanism is based on the standard Unix command "lp", which takes input either on the command line, or on its standard input file handle, and redirects the input to the printing system.
The command "lp" is responsible for the queuing of jobs in the print spool on Unix.
Interesting facts about "lp":
- the command "lp" (or "lpr") usually prints out on its standard output the print job number, when the stream of input data has been successfully queued.
- there is another command, usually called "lpq", which displays the list of all currently queued jobs on the system.
It is possible to control the generated job number when printing from the Progress/OpenEdge client:
1) print in a way that allow you to check the output of "lp" at the moment the job is queued
2) use "lpq" to monitor the print queue.
Option 1 requires to rewrite partially the printing code of the 4GL program, because OUTPUT TO PRINTER does not allow to read back data from the "lp" sub-process. The workaround is to proceed as follows:
1. write the data to print to a file
2. call "lp" with INPUT THROUGH, passing the file as a parameter.
Here is an example code:
OUTPUT TO printjob.
MESSAGE "hello, world".
OUTPUT CLOSE.
DEF VAR inl1 AS CHAR NO-UNDO.
DEF VAR inl2 AS CHAR NO-UNDO.
INPUT THROUGH lp printjob.
INPUT UNFORMATTED inl1.
INPUT UNFORMATTED inl2.
MESSAGE "message from lp: " SKIP inl1 SKIP inl2.
INPUT CLOSE.
Since the output from "lp" varies from system to system it is recommended to check on the specific system in use in order to decide how to use the data read back from the command.
Option 2 simply requires adding some code which uses the statement "INPUT THROUGH lpq" when you access to the print queue is needed. As the output from "lpq" varies from system to system it is recommended to try it first.