I have a script from a programmer, for which I need to analyze a problem.
The script gathers audit info and prints out the results. Two different departments use it, on two different printers. In the script department the there are no issues. In the other department the same script produces "problem" pages among the normal pages. They are either blank, or full of random collection of characters.
I need to put some kind of echo statements around the print functions and redirect it to a sort of error_show.txt file, so that we can see what is happening. We presume it is due to the usage of different printers.
If we can visualize the errors we can see if it is a problem with printer type or settings or whatnot.
This is the code
#!/usr/bin/sh
export PATH=/usr/bin:${PATH}
PRINTER="system"
ERRFILE=$(mktemp -c)
while getopts d: optchar; do
case $optchar in
d)
PRINTER=$OPTARG;;
esac
done
if [ -z "${PRINT_SERVER_HOME}" ]; then
[[ -f `cat /etc/PRINT_SERVER_HOME`/custom/etc/setup_env.sh ]] && . `cat /etc/PRINT_SERVER_HOME`/custom/etc/setup_env.sh
fi
if [ -z "${PRINT_SERVER_HOME}" ]; then
echo "Unable to setup PRINT_SERVER environment"
echo "Exitting..."
exit 1
fi
cd /var/spool/edi/ebill/audits
# We would like to print Audit files for AVAL
# if file aval.lst existed then delete it
if [ -e aval.lst ]; then
rm aval.lst
fi
# if avalaudt3.* exists then execute ll command below
if [ -e avalaudt3.* ]; then
ll avalaudt3.*>>aval.lst
fi
AVALFILELIST=$(gfind . -type f -name "avalaudt3.???" | sort -t'.' +2 )
AVALNEWFILELIST=""
for AVALFILE in ${AVALFILELIST}; do
if [ -s ${AVALFILE} ]; then
AVALNEWFILELIST="${AVALNEWFILELIST} $(pwd)/${AVALFILE##./}"
fi
done
# if file aval.lst exists and not empty
if [ -s aval.lst ]; then
${PRINT_SERVER_HOME}/bin/pdpr -d${PRINTER} -x"-start-sheet none" ${AVALNEWFILELIST} >${ERRFILE} 2>&1
fi
if [ $? -ne 0 ]; then
echo "ERROR: pdpr command failed for file aval.lst" >&2
cat ${ERRFILE} >&2
fi
rm -f ${ERRFILE} 2>/dev/null
I have highlighted the print function. Any help would be appreciated. The programmer inherited the script an doesn't want to delve too deeply into it.
I, however, would like to figure out what is happening and not waste the paper. However, this kind of script is way above my head, as of right now.
We're using HP's Output Server. And that is a custom pdpr command made by our boss. Works off of the command line, however it fails when used within a script.
If I use the syntax for pdpr on the command line, and list files like: /home/user/filelist.a* it will print without the random characters in between.
Have you tried printing to the opposing printer? Might eliminate the printer itself.
What is the make and model of each printer, and how are they connected to the network? Do they both have the same amount of internal memory?
Is this custom "pdpr" an alias, a script or what? Has $PATH been modified to find a different version when used from the command line? i.e. Are you sure that you are executing the same program from your script?
Slightly off topic (I think): Beware that $PRINTER is a system reserved Environment Variable name left over from early unix but still read by modern commands. It's usually mentioned in "man lp" to name but a few places.
The HP "Advance Printing Software" product is well documented for Tru64 unix, but would help to know what Operating System and version you have.