Print File Archiving


Contents

About this document
Solution summary
Caution
Procedure

About this document

This document describes how to use a simple shell script backend to make a copy of every print job sent to a file. The method described is more of a starting point than a final solution, but it may provide the insight to allow customization for a print archive solution for your organization.

This document applies to AIX Versions 3.2.5 and 4.x.


Solution summary

Create a queue that still uses a shell script as a backend that creates a unique file name and cats the file to that name.

This script then requeues the file with the flags on to the virtual printer print queue, which formats the data and sends it to the printer.


Caution

Only limited testing has been done to include passing the pitch and rotate flags using qprt. Only one file can be printed from a single print command with this script.


Procedure

  1. Create a shell script that can echo the flags. The location of this 'backend' script is not important, but the script should be in a directory with general permissions. The standard location for similar scripts in AIX 3.2.5 is /usr/lib/lpd/pio/etc.

    Backend script archive.sh

    # vi /usr/lib/lpd/pio/etc/archive.sh  and 'i'nsert the following
    #!/usr/bin/ksh
    # Sample backend archprt designed to archive a file and then print the
    # same file to another AIX queue.
    #
    # DISCLAIMER:  This is example code from John Tesch at the AIX Systems
    # center.  This code had not passed any verification testing and is
    # simply provided as an example of how to start in creating your
    # own backend.  Special customization of this file and questions
    # concerning customer special needs are considered consulting issues
    # and will be handled under 'CONSULT LINE' services of the AIX Systems
    # Center's Support Family.
    #
    # This script assumes that there is a count file for each user setup.
    # This script sets them up in /tmp, but they could be in a /var/spool/count
    # directory.
    # It also assumes a PTYPE environment variable in the users .profile
    # export PTYPE=APPS or similar to designate where file came from.
    # This is not necessary.  If the PTYPE variable is not set, then the
    # archived files will be username.number
    # Special attention has been paid to pass print flags to the REAL
    # print queue, but this has only been tested with qprt on a couple of
    # flags.
    # These lines are for debug purposes only.  You don't need these in
    # the working backend.  These are primarily included to help the
    # user understand what is really going on in the rest of the script.
    # Echo all parameters
    echo $@ > /tmp/flags.out
    # Echo the number of parameters
    echo $# >> /tmp/flags.out
    # Echo the username who submitted the job
    echo $USER >> /tmp/flags.out
    # Echo users PTYPE environment variable.
    echo $PTYPE >> /tmp/flags.out
    # Echo base of file name for archive.
    echo $USER.$PTYPE >> /tmp/flags.out
    # Echo file name of file being printed.  It is always the last argument.
    eval "echo \$$# >> /tmp/flags.out"
    # Start of real code, first create unique number for each user.
    read i < /tmp/$USER.cnt
    # Always cat the file which is the last parameter
    # Cat to the archive file username.xxxnumber where xxx is user
    # environment variable PTYPE.
    eval "cat \$$# > /tmp/$USER.$PTYPE$i"
    let i=i+1
    echo $i > /tmp/$USER.cnt
    # Let the job copy before ending which will delete the temp. file.
    qprt -c -Pasc $@
    # The sleep time may need to be adjusted.
    sleep 10
    
  2. Save the file and change the file ownership and permissions:
    	'chmod +x /usr/lib/lpd/pio/etc/archive.sh'
    	'chgrp printq /usr/lib/lpd/pio/etc/archive.sh'
    
  3. Add a local queue.

    In AIX 3.2:

    	smit mkque
    		 Add a Local Queue
    Fill in form: Name of queue, Name of device.., BACKEND PROGRAM pathname	
                                   Add a Local Queue
    Type or select values in entry fields.
    Press Enter AFTER making all desired changes.
      
                                                            [Entry Fields]
    * NAME of queue to add                  ------>      [testq]
      ACTIVATE the queue?                                yes                 +
      Will this become the DEFAULT queue?                no                  +
      Queuing DISCIPLINE                             first come first serve  +
      ACCOUNTING FILE pathname                           []
    * NAME of device to add                 ------>      [testd]
      BACKEND OUTPUT FILE pathname          ------>      [FALSE]
      ACCESS MODE of backend output file                 write only          +
    * BACKEND PROGRAM pathname     ------>   [/usr/lib/lpd/pio/etc/archive.sh]
      Number of FORM FEEDS prior to printing             [0]                 #
      Print HEADER pages?                                 never              +
      Print TRAILER pages?                                never              +
      ALIGN pages between files within jobs?              yes                +
    Press Enter to add queue.
    
    In AIX 4:
        smit mkpq
           other                User Defined Backend
    * Name of QUEUE to add                               [arch]
    * Name of QUEUE DEVICE to add                        [archd]
    * BACKEND PROGRAM pathname           [/usr/lib/lpd/pio/erc/archive.sh] 
      ACTIVATE the queue?                                 yes   
      Should this become the DEFAULT queue?               no   
      Queuing DISCIPLINE                                  first come first serve
      ACCOUNTING FILE pathname                           [] 
      HOSTNAME of remote server                          []
      Name of QUEUE on remote server                     []
      Pathname of the SHORT FORM FILTER for queue        []
       status output
      Pathname of the LONG FORM FILTER for queue         []
       status output
      BACKEND OUTPUT FILE pathname                       []
    
  4. Test the queue.

    • # export PTYPE=appid

      For appid use something to key on when looking for the file. It will be used as part of the file name by the program.

    • # qprt -Ptestq /etc/motd

    • # lpstat -vtestq

      This should show:

      Queue   Dev   Status    Job Files        User         PP %   Blks  Cp Rnk
      ------- ----- --------- --- ------------ ---------- ---- -- ----- --- ---
      testq   testd READY    
      
    • # cat /tmp/flags.test

      This shows an example. This file and the writes to it are merely for debugging the backend and can be removed from the archive.sh script once things are working.

      /var/spool/qdaemon/tOqYDXr
      jwtesch
      APP
      jwtesch.APP
      3
      
    • # ls /tmp/jw*

      This shows files created.

      /tmp/jwtesch.APP2  /tmp/jwtesch.APP3  /tmp/jwtesch.cnt
      




[ Doc Ref: 9174712158698     Publish Date: Feb. 09, 2001     4FAX Ref: 6454 ]