source: trunk/locker/sbin/mail-owners.pl @ 1400

Last change on this file since 1400 was 752, checked in by njess, 16 years ago
Script to mail to locker owners
  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/athena/bin/perl
2
3use strict;
4
5use warnings;
6
7open LIST, "actual";
8
9open TEMPLATE, "wordpress-email";
10
11my $template = do {local $/; <TEMPLATE>};
12
13sub bits {
14    # Given the argument of a locker, return users with rlidwka rights
15    my $DIR = shift;
16    open PERM, "fs la $DIR | ";
17    my @list = (); #to be filled with users or moira lists
18    while (my $line = <PERM>){
19        if ($line =~ m{(\S+) \s rlidwka}x) {
20            my $temp = $1;
21            $temp =~ s/system://g;         
22            push @list, $temp;
23        }
24    }
25    return @list;
26}
27
28while (my $line = <LIST>) {
29    print $line;
30    if ($line =~ m{( (.*/ ([^/]+) ) /web_scripts/(\S+) )\s.*'([.0-9]+)'}x) { 
31        my $PATH = $1;
32        #print $PATH;
33        my $DIR = $2;
34        my $LOCKER = $3;
35        my $URI = "$3.scripts.mit.edu/$4";
36        my $VERSION = $5;
37        next if $VERSION ne '2.0.2';
38        my $lockeremail = $template;
39        $lockeremail =~ s/<LOCKER>/$LOCKER/g;
40        $lockeremail =~ s/<URI>/$URI/g;
41        $lockeremail =~ s/<DIRECTORY>/$PATH/g;
42        $lockeremail =~ s/<VERSION>/$VERSION/g;
43        $lockeremail = "To: ".join(',',&bits($DIR))."\n\n".$lockeremail; 
44        open OUTPUT, ">./email/$LOCKER";
45        print OUTPUT $lockeremail; 
46    }
47}
48
49
50
51
52
53
Note: See TracBrowser for help on using the repository browser.