[SLUG] Perl script, printing trouble

From: Doug Koobs (dkoobs@dkoobs.com)
Date: Thu Aug 26 2004 - 15:23:47 EDT


I could use some help with a Perl script that monitors a directory, and
decrypts and prints any files that show up there. The decrypt part works
fine, but the printing is not consistent. I'm using enscript to create a
postscript file, and then lpr to print it. (originally, I was only using
enscript, but I've split the process into two steps for troubleshooting
purposes).

Here's the piece I'm having trouble with:

#create ps file
system ("enscript -fTimes-Roman10 -p$root_dir\/temp\/$print_file $proc_dir/
$print_file");

#print ps file
system ("lpr -P okipage $root_dir\/temp\/$print_file");

#get return code from lpr
$lpr_exit = $?;
#if printing failed
if ($lpr_exit ne 0) {
        print OUTPUT "[$now]|FAILED|$aclient|$filename|Print
error|$enscript_exit|$!\n";
        open(MAIL, "|/bin/mail -s \"FCS Inbound Proc Print NOT Successful\"
it_admin\@fcsservices.com");
        print MAIL "File \"$filename\" was NOT printed correctly.";
        close(MAIL);
        }
        else
#if printing succeeded
        {
        print OUTPUT "[$now]|$aclient|$proc_dir|$filename|File Printed
Successfully\n";
        }
}

We receive a set of files daily that this script processes. Some of them
print successfully, some don't. But, the log entries for each file say
"File Printed Successfully" (from the last "print OUTPUT" statement). The
enscript command is creating the files in the proper temp directory. If I
go into that directory and run

lpr -P okipage *

they all print fine.

Why am I not getting error messages when the print fails? Evidently, lpr
is handing of the job to some other process successfully, and reporting
success. What process is lpr handing it to, and how can I monitor it? The
printer that it is printing to is a network printer, with a NIC module.

Thanks!

Doug

Fine Print: I apologize if the formatting of the script gets mangled...
Also, the variables you see above have all been defined and assigned
values prior to this snippet of the script. The OUTPUT handle was also
previously opened, and closed later.

-----------------------------------------------------------------------
This list is provided as an unmoderated internet service by Networked
Knowledge Systems (NKS). Views and opinions expressed in messages
posted are those of the author and do not necessarily reflect the
official policy or position of NKS or any of its employees.



This archive was generated by hypermail 2.1.3 : Fri Aug 01 2014 - 15:30:32 EDT