PxPlus User Forum

Twitter Twitter Twitter

Author Topic: Interfacing with the Unix/Linux spooler  (Read 867 times)


  • Administrator
  • Diamond Member
  • *****
  • Posts: 1062
    • View Profile
Interfacing with the Unix/Linux spooler
« on: July 03, 2018, 06:30:16 PM »
While on Windows system you can directly open *WINPRT* to send data to the windows spooler, on Unix/Linux systems there is no such built in mechanism.

You can however setup a PxPlus 'LINK' file which will provide a similar functionality.  A LINK file is basically just a small file that resides on your system that contains the name of file your really want to open and the name of a device driver you want to be run immediately after opening the file and before returning to the application.  These LINK files can be created using the *UCL utility which will ask for the name of the real file to open and the device driver.

To create a LINK file to the Unix/Linux spooler first create a device driver which will be invoked when the file is opened.  A device driver for the spooler would look something like this:

Code: [Select]
! SPOOLEDHP - Unix spooler driver for HP laser compatible printer
Title$ = OPT(LFO) ! Get title from OPT= in the open
if Title$="" Title$="Report for "+WHO ! Default report title
CLOSE (X) ! Close dummy file
OPEN (X) ">lp -s -dP015 -t '"+title$+"' 1>/dev/null 2>/dev/null"
RUN "*dev/hp_laser"

Save this driver as "*dev/spooledhp".

Now create a Link file using *UCL with a targte pathname of /dev/null and specifying this driver.

When you subsequently open the link file, the system will temporarily open /dev/null then internally CALL"*dev/spooledhp"

The logic shown above will close the connection to /dev/null, and re-open it as a pipe to the system spooler.  The program also also includes the ability for you to specify OPT="Title" in your OPEN directive to set the title of the report to be passed to the system spooler.  If no OPT= is on the OPEN directive, the title of "Report for username" will be used. 

For Example, assuming you created the LINK file of printer_1:

  • OPEN (1,OPT="Product Report") "printer_1"
This would output a report with a title of Product Report to printer P015 using the Unix/Linux spooler.

Note: The value -dP015 in the command line shown in the code is specifying the printer name as P015.  You will need to change this to suit your system.  Also note the program ultimately runs *dev/hplaser which is a PxPlus supplied driver for HP compatible printers.