3 # This script prints the letters confirming registration for the extra
6 # The algorithm consists of first checking to see that the previous
7 # day's job printed. If so, the cached copy is deleted. Otherwise,
8 # today's is appended to yesterday's and we continue working with that.
11 $newfile = "/tmp/letter.out";
12 $savefile = "/u1/letter.save";
13 $holdfile = "/u1/letter.hold";
14 $logfile = "/u1/letter.log";
16 open(LOG, ">>" . $logfile);
18 print LOG "\nRunning " . `date`;
20 $printed =`/usr/athena/bin/lpquota -l | tail -2`;
21 @printed = split(/\s+/, $printed);
23 print LOG "\nlast printed " . $printed;
25 $filed = `ls -l $savefile`;
26 @filed = split(/\s+/, $filed);
28 print LOG "\nfile touched " . $filed;
30 if ($printed[1] eq $filed[4] && $printed[2] eq $filed[5]) {
31 system("mv $newfile $savefile");
35 if ( ! -f $holdfile) {
36 open(MAIL, "|/bin/mail dbadmin thorne");
37 print MAIL "To: dbadmin, thorne\n";
38 print MAIL "Subject: reg_extra printing error\n";
39 print MAIL "Reg_extra letters failed to print yesterday\n";
43 print LOG "\nmail sent";
45 system("cat $newfile >> $savefile");
47 system("mv $newfile $savefile");
53 print LOG "\nprinting...";
55 open(OUT, "/usr/ucb/lpr -P$printer -h $savefile|");
61 if ($msg eq "Printer queue is disabled.\n") {
64 print LOG "got expected queue down error\n";