ITEM: V7323L
How to archive print copies?
Question:
Customer wants to see if there is an option he can use
when printing to send the file to the printer and also save a
copy (after formatting) to a file.
Response: The following HOW TO describes a typical solution
to this problem.
PRINT FILE ARCHIVING
Version 1.1, June 20, 1995
Author: John Tesch, Ph.D., AIX Systems Center
How to make a copy of every file printed.
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 at a
time using this method.
Steps for howto:
1. Create a shell script that can echo the flags. The location
of this 'backend' script is not important. The standard location
for similar scripts in AIX 3.2.5 is /usr/lib/lpd/pio/etc.
\# 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 is
\# 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
\# I have set mine up in /tmp, but they could be in a /var/spool/count
\# directory.
\# It also assumes a PTYPE environment variable in the users .pro
\# 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 I have only tested this 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
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'
2. Add a local queue
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.
3. Test the queue
\# export PTYPE=APP
\# qprt -p17 -z+ -Ptestq /etc/motd
\# lpstat -vtestq
should show:
Queue Dev Status Job Files User PP % Blks Cp Rnk
------- ----- --------- --- --------- ---- -- ----- --- ---
testq testd READY or RUNNING
\# cat /tmp/flags.test Shows example.
-p 17 -z + /var/spool/qdaemon/tOqYDXr
jwtesch
APP
jwtesch.APP
3/var/spool/qdaemon/tOqYDXr
\# ls /tmp/jw* Shows files created.
/tmp/jwtesch.APP2 2nd file printed for jwtesch
/tmp/jwtesch.APP3 3rd file printed for jwtesch
/tmp/jwtesch.cnt File containing count for user jwtesch
Support Line: How to archive print copies? ITEM: V7323L
Dated: June 1995 Category: N/A
This HTML file was generated 99/06/24~13:30:34
Comments or suggestions?
Contact us