This document describes a number of simple Korn shell printer backend programs that can be useful for solving simple problems, such as finding what flags are being passed to the backend and converting one flag to another.
This document describes techniques applicable to all levels of AIX.
Sometimes printing problems can be related to illegal flag values that are being sent. A shell script can be used to determine which flags were passed, and can even resubmit the job with the same of new flags. The following script would satisfy this requirement.
#!/bin/ksh date >> /tmp/flags echo $@ >> /tmp/flags enq -Pnew_queue_name $@
It is recommended that you set the permissions on /tmp/flags so that everyone can write to this file. Make sure you set the permissions on the shell script so that everyone can execute it as well. Also make sure you place it in a directory easily accessible by all.
Sometimes you want to ignore all flags coming in and build your own print command with the flags that you want to use. In this case, you can simply extract the file names from the options passed and build the new command. This example only works with one file at a time because it is based on the attribute that gives only the last parameter passed to the backend, namely the \$$# ksh construct. Note that this seems to work best in an eval statement as shown below (the sleep gives a little time for the copy to complete):
#!/bin/ksh # It is always useful to add some logging in these scripts date >> /tmp/flags eval "qprt -dp -c -z+ -p14 -v8 -Ppcl04 \$$#" sleep 5
#/bin/ksh # while getopts :J:X:b:cf: arguments do case $arguments in X) print "You entered a -X option of $OPTARG";; :) print "Your forgot the -X argument";; J) print "You entered a -J option of $OPTARG";; b) print "You entered a -b option of $OPTARG";; c) print "You entered a -c option";; f) print "You entered a -f option of $OPTARG";; \?) print "You entered $OPTARG";; esac done ((current_position = OPTIND -1)) shift $current_position echo "Left at $1" echo "Number of arguments left is $#"
To turn this into a backend, remove the print statements and replace them with actions that are appropriate, such as building a flag string. Then extract the file names and add a print statement. This illustrates how to capture the flags, but uses only the -X flags.
#/bin/ksh # This testpr.sh script is designed to print overlays # when initiated by HCON, but should also work for other # types of printing. # while getopts :J:L:X:Z:b:ci:j:l:p:s:t:u:v:w:x:y:z: arguments do case $arguments in ## $OPTARG X) Xflags="-X $OPTARG" ;; J) Jflags="-J $OPTARG" ;; L) Lflags="-L $OPTARG" ;; Z) Zflags="-Z $OPTARG" ;; b) bflags="-b $OPTARG" ;; c) cflags="-c $OPTARG" ;; f) fflags="-f $OPTARG" ;; g) gflags="-g $OPTARG" ;; i) iflags="-i $OPTARG" ;; j) jflags="-j $OPTARG" ;; l) lflags="-l $OPTARG" ;; p) pflags="-p $OPTARG" ;; s) sflags="-s $OPTARG" ;; t) tflags="-t $OPTARG" ;; u) uflags="-u $OPTARG" ;; v) vflags="-v $OPTARG" ;; w) wflags="-w $OPTARG" ;; x) xflags="-x $OPTARG" ;; y) yflags="-y $OPTARG" ;; z) zflags="-z $OPTARG" ;; \?) ;; esac done ((current_position = OPTIND -1)) shift $current_position date >> /tmp/flags.out echo "Number of files to print $#" >> /tmp/flags.out echo "Filenames were: $*" >> /tmp/flags.out qprt -Ppcl -Z! -p14 -f2 -dp -z+ -v8 $Xflags $*
[ Doc Ref: 9179090839662 Publish Date: Feb. 13, 2001 4FAX Ref: 6441 ]