AIX Printer Tips: Capturing a Spool File in AIX

Contents

About This Document
Abstract
Printing To a File in the /dev/ Directory
Capturing a File As It Enters the Queue
Capturing Print File Sent Over the Network
Use a Custom Backend

About This Document

This document describes several ways to capture files and look at them as they pass through the AIX spool system. This information applies to AIX Version 4 and later.

Abstract

In problem determination, it is often useful to look at the file being printed through different states of the print process. There are a number of options for capturing a spool file in AIX depending on the reason for capturing data. Here are four basic methods:
  1. Create a file in /dev/, and make a print queue to a file.
  2. Print to a disabled queue, and use lpstat -t to find the location of the file.
  3. Use iptrace to trace the file as it goes to a network print server or printer.
  4. Use a custom backend.

1. Printing To a File in the /dev/ Directory

By adding a print queue that prints to a file, it is able to see exactly how the virtual printer modifies the file being printed. The commands sent to the printer can be analyzed and compared with the commands expected based on the printers technical reference manual. By combining this with method 2 (Capturing the file as it enters the queue) one can see exactly what is added by a particular virtual printer and the effect of qprt print flags and virtual printer customization.

Procedure

  1. Create the file in /dev/lpx
  2.     cat /dev/null > /dev/capture
        chgrp printq /dev/capture
        chmod 777 /dev/capture
    
  3. To create the queue at AIX 4, do the following.
  4. Print to the file.
  5. echo "AAAAA" | qprt -Pqueue_name - Easy to find in capture file
    qprt -P<queue> <filename>

  6. View the results
  7. To rezero the capture file
  8. cat /dev/null > /dev/capture'

2. Capturing a File As It Enters the Queue

Capturing a file as it enters a queue is useful in at least two circumstances.
  1. Sometimes the problems resulting from improper formatting are created by the application. To see exactly what is in the application one can disable the queue and capture the spool file.
  2. When print from a client to an AIX host, sometimes the print flags sent by the client cause problems on AIX. To make sure the problem is not with the file, one can capture the spool file and print it locally.

Procedure

  1. Create any queue as described in step one or disable an existing queue.

  2. For example we will call the queue capture

  3. Disable the queue.
  4. disable capture

  5. Print to the queue
  6. Check the queue status to see job is printed
  7. lpstat -t -vcapture Don't leave space between v and capture.
    The minus "t" flag causes the file to be displayed.

    Queue   Dev   Status    Job Files              User      
    ------- ----- --------- --- ------------------ ---------- 
    capture captu DOWN     
                  QUEUED    147 STDIN.23330   jwtesch@aixnts
                    03/05/97 09:21:04    1  15          2   1               
                          /var/spool/lpd/dfA692aixnts
    
  8. If users is printing from remote then actual file will always be in /var/spool/lpd probably starting with dfA. If the file was printed on the local system, then it will either be the original file name, or a file in /var/spool/qdaemon.
  9. Look at the file.
  10. Look at the flags in the job description file
  11. One of the things that affects the processing of a job that has been sent to an AIX queue is the flags that have been used in the printing process.  Because all of the print commands in AIX call the enq print program, it can sometimes be surprising what enq flags are generated by the different commands.  For example issuing the print command lpr calls enq with a -c flag and a -Ban.  This means that the file is copied to /var/spool/qdaemon before being printed, and that it will always have a header page. To see the job description file follow these steps:
    cd /var/spool/lpd/qdir  -  This directory contains the job description file for all jobs that are queued.
    ls -l   shows which jobs are currently queued.  You will be able to identify the file for your job because the file name will contain the user id and the queue.
    pg <file_name>  and look for flags as shown below:
     

  12. Remove the job from the queue

  13. Nothing will get sent to /dev/capture.

    cancel ### where ### is the job name.
    cancel 363
    cancel capture to remove all files from queue.
     

3. Capturing Print File Sent Over the Network.

Remote printing jobs in AIX can be captured with the iptrace utility.  This is discussed in more detail in the technical document AIX Printer Tips: Tracing Remote Printing, and this document contains only a brief outline of how to look at the print job itself as it passes over the network.  The reason that you might want to trace the data passing over the network is to determine where problems occurred when the output on the printer is different than you had hoped for.  The steps to capturing remote print jobs are:

  1. Start iptrace running with the following command:
     iptrace -p printer -a -b -s source_host -d dest_host /tmp/trace.out
    

  2. Now print to the queue

      enq -Pqueue_name filename
    

    Print the job to the remote queue.
    Or use lpstat -vqueue_name if you want to trace the status report.

  3. Check the size of the trace file.
      ls -l /tmp/trace.out
    

    Check to see if the file has grown. If it is still 11 bytes, then you have done something wrong in you command, kill and retry.

  4. Find the process ID of the iptrace command.
       ps -ef | grep ipt
    

  5. Get the process id from the output and kill this process.
      kill -9 process_id
    
  6. Format the trace data to create a text file you can view and print.
      ipreport /tmp/trace.out > /tmp/report.out
    
  7. To see the data only, you can now grep the report with four zero's
      grep 0000 /tmp/report.out
    

    This will show all the data that passes over the network in both hexadecimal and ascii text, allowing you to compare with the starting file, as well as what printed on the remote printer.

    4. Use a Custom Backend

      A simple backend can be used to look at flags and at the file.

      This gives the option to write a program that archives the data to a specific file. Some hints while developing this script are to use a shell script with commands like:

      • Start script with #!/bin/ksh
      • echo &quotParms are: $*" > /tmp/flags to find out what flag was send.
      • echo &quotArgs = *#" >> /tmp/flags' to see how may arguments are passed.
      • cat $1 > /tmp/filename to save the file if only one argument was passed to the queue. Use $2 for 2 arguments and so on.

      When adding the script backend add the queue as follows: AIX 4.1

      • Give script executable permissions and put in printq group.
      • smitty mkpq
      • Select: other ----------------- User Defined Backend
      • Name of QUEUE to add:--------- qname
      • Name of QUEUE DEVICE to add:-- qnamed
      • BACKEND PROGRAM pathname:--- /usr/lbin/myback.sh
    For more information about custom backend programs, contact your AIX service representative.


    Capturing a Spool File in AIX: AIX Printer Tips: capture.html ITEM: FAX
    Dated: 99/02/24~00:00 Category: zap
    This HTML file was generated 99/06/24~12:42:11
    Comments or suggestions? Contact us