Capturing a Spool File in AIX


Contents

About this document
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 and see files as they pass through the AIX spool system. This information applies to AIX Versions 4 and later.

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. This is useful to see the data after it has gone through the backend.
  2. Print to a disabled queue and use the command lpstat -t to find the location of the file. This is useful to see the file before it goes to the queue backend.
  3. Use iptrace to trace the file as it goes to a network print server or printer.
  4. Use a custom backend. This gives the option to write a program that archives the data to a specific file.

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 the second method, "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. Enter the following sequence of commands:
        cat /dev/null > /dev/capture
        chgrp printq /dev/capture
        chmod 777 /dev/capture
    
  2. To create the queue at AIX 4, do the following:

  3. Print to the file. Enter:
    echo "AAAAA" | qprt -Pqueue_name    (This is easy to find in the capture file.)
    qprt -P<queue> <filename>

  4. View the results and complete the following steps:
    • Enter cat -v /dev/capture.
    • To see the results, enter vi /dev/capture.
    • To identify control characters, enter od -ca /dev/capture.

  5. To rezero the capture file, enter:
    cat /dev/null > /dev/capture'
    

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, disable the queue and capture the spool file.
  2. When printing from a client to an AIX host, the print flags sent by the client may cause problems on AIX. To make sure the problem is not with the file, capture the spool file and print it locally.

Procedure

  1. Create any queue as described in step one or disable an existing queue. For example, we will call the queue capture.

  2. Disable the queue. Enter:
    disable capture
    

  3. Print to the queue.

  4. Check the queue status to see that the job has printed. Enter:
    lpstat -t -vcapture
    
    Do not leave a space between v and capture. The -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
    
  5. If users are printing remotely, then the actual file will 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.
  6. Examine the file. Complete the following steps.

  7. Look at the flags in the job description file. The processing of a job that has been sent to an AIX queue is affected by 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 have a header page.

    To see the job description file, follow these steps:

  8. Remove the job from the queue.

    Nothing will be sent to /dev/capture.


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 Tracing Remote Printing. This document contains only a brief outline of how to look at the print job itself as it passes over the network. Tracing the data that passes over the network may help determine where problems occurred when the output on the printer is different than what was expected. 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. Enter:
      enq -Pqueue_name <filename>
    
    Print the job to the remote queue or use lpstat -v<queue_name> if you want to trace the status report.

  3. Check the size of the trace file. Enter:
      ls -l /tmp/trace.out
    
    Check if the file has grown. If it is still 11 bytes, then the command has been issued incorrectly. Kill the process and retry.

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

  5. Get the process ID from the output and kill this process. Enter:
      kill -9 <process_id>
    
  6. Format the trace data to create a text file you can view and print. Enter:
      ipreport /tmp/trace.out > /tmp/report.out
    
  7. To see the data only, you can now grep the report with four zeros. Enter:
      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.


    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 the script with #!/bin/ksh.
      • To find out what flag was sent, enter echo &quotParms are: $*" > /tmp/flags.
      • To see how many arguments are passed, enter echo &quotArgs = *#" >> /tmp/flags'.
      • To save the file if only one argument was passed to the queue, enter cat $1 > /tmp/filename. Use $2 for 2 arguments and so on.

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

      • Give the script executable permissions and put it in the printq group.
      • Enter 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.




    [ Doc Ref: 91755795210916     Publish Date: Mar. 06, 2001     4FAX Ref: 6478 ]