]> andersk Git - moira.git/blob - gen/letter.pl
New database and column names for Moira2.
[moira.git] / gen / letter.pl
1 #!/moira/bin/perl
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
10 $printer = "linus";
11 $newfile  = "/tmp/letter.out";
12 $savefile = "/u1/letter.save";
13 $holdfile = "/u1/letter.hold";
14
15 $printed =`lpquota -l | tail -2`;
16 @printed = split(/\s+/, $printed);
17
18 $filed = `ls -l $savefile`;
19 @filed = split(/\s+/, $filed);
20
21 if ($printed[1] eq $filed[4] && $printed[2] eq $filed[5]) {
22     system("mv $newfile $savefile");
23 } else  {
24     if ( -s $savefile) {
25         if ( ! -f $holdfile) {
26             open(MAIL, "|/bin/mail dbadmin thorne");
27             print MAIL "To: dbadmin, thorne\n";
28             print MAIL "Subject: reg_extra printing error\n";
29             print MAIL "Reg_extra letters failed to print yesterday\n";
30             print MAIL $filed;
31             print MAIL $printed;
32             close(MAIL);
33         }
34         system("cat $newfile >> $savefile");
35     } else {
36         system("mv $newfile $savefile");
37     }
38 }
39
40 unlink($holdfile);
41
42 open(OUT, "lpr -P$printer -h $savefile|");
43 $msg = <OUT>;
44 close(OUT);
45
46 if ($msg eq "Printer queue is disabled.") {
47     open(FOO, $holdfile);
48     close(FOO);
49 }
50
51 exit 0;
This page took 0.197847 seconds and 5 git commands to generate.