]> andersk Git - moira.git/blame - gen/letter.sh
Diane Delgado's changes for a fixed table-locking order
[moira.git] / gen / letter.sh
CommitLineData
b00a5d90 1#!/moira/bin/perl
78c00fd3 2# $Header$
3# This script prints the letters confirming registration for the extra
4# kerberos principal.
5
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.
9
b00a5d90 10$printer = "nil";
11$newfile = "/tmp/letter.out";
12$savefile = "/u1/letter.save";
13$holdfile = "/u1/letter.hold";
14$logfile = "/u1/letter.log";
15
16open(LOG, ">>" . $logfile);
17
18print LOG "\nRunning " . `date`;
19
20$printed =`/usr/athena/bin/lpquota -l | tail -2`;
21@printed = split(/\s+/, $printed);
22
23print LOG "\nlast printed " . $printed;
24
25$filed = `ls -l $savefile`;
26@filed = split(/\s+/, $filed);
27
28print LOG "\nfile touched " . $filed;
29
30if ($printed[1] eq $filed[4] && $printed[2] eq $filed[5]) {
31 system("mv $newfile $savefile");
32 print LOG "\nall OK";
33} else {
34 if ( -s $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";
40 print MAIL $filed;
41 print MAIL $printed;
42 close(MAIL);
43 print LOG "\nmail sent";
44 }
45 system("cat $newfile >> $savefile");
46 } else {
47 system("mv $newfile $savefile");
48 }
49}
50
51unlink($holdfile);
52
53print LOG "\nprinting...";
54
55open(OUT, "/usr/ucb/lpr -P$printer -h $savefile|");
56$msg = <OUT>;
57close(OUT);
58
59print LOG "done\n";
60
61if ($msg eq "Printer queue is disabled.\n") {
62 open(FOO, $holdfile);
63 close(FOO);
64 print LOG "got expected queue down error\n";
65}
66
67exit 0;
This page took 0.648101 seconds and 5 git commands to generate.