]>
Commit | Line | Data |
---|---|---|
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 | ||
16 | open(LOG, ">>" . $logfile); | |
17 | ||
18 | print LOG "\nRunning " . `date`; | |
19 | ||
20 | $printed =`/usr/athena/bin/lpquota -l | tail -2`; | |
21 | @printed = split(/\s+/, $printed); | |
22 | ||
23 | print LOG "\nlast printed " . $printed; | |
24 | ||
25 | $filed = `ls -l $savefile`; | |
26 | @filed = split(/\s+/, $filed); | |
27 | ||
28 | print LOG "\nfile touched " . $filed; | |
29 | ||
30 | if ($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 | ||
51 | unlink($holdfile); | |
52 | ||
53 | print LOG "\nprinting..."; | |
54 | ||
55 | open(OUT, "/usr/ucb/lpr -P$printer -h $savefile|"); | |
56 | $msg = <OUT>; | |
57 | close(OUT); | |
58 | ||
59 | print LOG "done\n"; | |
60 | ||
61 | if ($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 | ||
67 | exit 0; |