Printing a Document (UNIX and z/OS)

Printing a document on UNIX and z/OS can be done similarly to Windows in that an invoked shell script can execute commands or other necessary processing. That is, you write a shell script that is invoked by the XML Server as per your configuration and the shell script performs the processing specific to the platform. For example, see Printing a Document (UNIX and z/OS) below. Let us assume that the shell script is saved as /usr/local/xmlsrv/xmlserver.sh1. The server command can pass arguments to the shell script, which are accessed in a typical way: $1 for the first parameter, $2 for the second, etc. These arguments are provided to the shell script via the server command tokens specified in the script invocation in the server configuration file and replaced when the script is invoked. (See Server Command Configuration and Printing a Document (UNIX and z/OS) for more information on command tokens.)

In general, printing capabilities vary widely by OS distribution, version, installed software, physical printer capabilities, etc. Review your local environment for requirements and how to best implement printing support. For instance, a z/OS implementation might use the IBM® InfoPrint Server2.

The following example illustrates how printing might be done on various UNIX platforms. For instance, as on z/OS, if the software and printer hardware supports it direct printing via the the system print command (lp or lpr) may be possible. On IBM AIX® you would require third-party software to convert the input PDF to PostScript for printing. For ease of monitoring the script contains echo commands to provide progress during its execution and appends the output to a file named XMLServer.log.

Note: On the z/OS platform you will have to covert the encoding of the xmlserverprint.sh script from ASCII to EBCDIC. For example:
tr -d '\15\32' < xmlserverprint.sh > xmlserverprint.sh-ASCII
iconv -t IBM-1047 -f ISO8859-1 xmlserverprint.sh-ASCII \
> xmlserverprint.sh
chmod a+rx xmlserverprint.sh
Figure 1. Sample Shell Script for Printing a Document (UNIX and z/OS)
#!/bin/sh

# Sample UNIX script for XMLServer printing.

echo ---------------------------------------------------- \
  >> XMLServer.log
# log output
echo File:         $1          >> XMLServer.log
echo Print Server: $2          >> XMLServer.log
Platform=`/bin/uname`
echo Platform:     $Platform   >> XMLServer.log

# The following illustrates some possible print solutions
# for various platforms:

case $Platform in
  # z/OS:
  OS/390)
    # On OS/390 (z/OS) use of the lop command as 
    # illustrated would be dependent on the InfoPrint
    # Server installation and configuration, related 
    # software, and a printer with direct PDF support
    # and sufficient memory.
    echo Starting print...    >> XMLServer.log
    lp -d $2 $1
    echo Printing Completed   >> XMLServer.log
  ;;

  AIX)
    # AIX has no native print support for PDF files,
    # so you would need to implement functionality such as
    # pdf2ps to convert the generated PDF file to
    # PostScript for printing with lpr; e.g.:
    # see the IBM Redbook SG24-6018-00
    #   pdf2ps $1 $1.ps
    #   lpr -P $2 $1.ps
    echo $Platform printing implementation is TBD. \
      >> XMLServer.log
  ;;

  # Other platforms:
  *)
    # Your local print functionality to be implemented here ...
    echo $Platform printing implementation is TBD. \
      >> XMLServer.log
  ;;
esac

echo ---------------------------------------------------- \
  >> XMLServer.log

The configuration file used to launch this shell script is shown in Printing a Document (UNIX and z/OS) below. Note how the printer name (%p) and the details of the temporary file (%d and %f) are passed to the shell script using the command tokens. These are interpreted by the shell as two arguments inside the script: 1) The temporary directory and file name are concatenated with a forward-slash separator; and 2) name of the printer, which may be overridden by the client. See Server Command Configuration for a more detailed description of these tokens.

Figure 2. Configuration for Printing a Document (UNIX and z/OS)
<XML_SERVER_CONFIG>
  ...
  <SERVER_COMMAND>
    ./xmlserverprint.sh %d/%f %p
  </SERVER_COMMAND>
  <USE_TMP_FILE>true</USE_TMP_FILE>
  <TMP_DIRECTORY>./tmp</TMP_DIRECTORY>
  <TMP_FILE_ROOT>doc</TMP_FILE_ROOT>
  <DEFAULT_PRINTER>printer1</DEFAULT_PRINTER>
  ...
</XML_SERVER_CONFIG>
1 Note that you should choose a target destination for setting up your XML Server and its customizations to avoid being overwritten by subsequent service pack updates.
2 The installation and configuration of the InfoPrint Server is beyond the scope of this document.