]> andersk Git - moira.git/blob - gen/longjobs.gen
Command line printer manipulation client, and build goo.
[moira.git] / gen / longjobs.gen
1 #!/moira/bin/perl -Tw
2
3 # $Id$
4
5 # The following exit codes are defined and MUST BE CONSISTENT with the
6 # error codes the library uses:
7 $MR_DBMS_ERR = 47836421;
8 $MR_OCONFIG = 47836460;
9
10 $outfile = '/moira/dcm/longjobs.out';
11
12 use DBI;
13
14 $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
15   || exit $MR_DBMS_ERR;
16
17 $sth = $dbh->prepare("SELECT name FROM list WHERE grouplist = 1")
18     || exit $MR_DBMS_ERR;
19
20 $sth->execute || exit $MR_DBMS_ERR;
21
22 umask 022;
23 open(OUT, ">$outfile") || exit $MR_OCONFIG;
24
25 while ($name = $sth->fetchrow_array) {
26     
27     $sth2 = $dbh->prepare("SELECT UNIQUE u.login FROM users u, imembers i, " .
28                           "list l WHERE l.name = " . $dbh->quote($name) .
29                           "AND l.list_id = i.list_id " .
30                           "AND i.member_type = 'USER' " .
31                           "AND i.member_id = u.users_id") || exit $MR_DBMS_ERR;
32
33     $sth2->execute || exit $MR_DBMS_ERR;
34                  
35     $row = "$name:";
36     $row =~ s/\0//g;
37     print OUT $row;
38     $maybecomma = "";
39
40     while ($member = $sth2->fetchrow_array) {
41         $row = "$maybecomma$member";
42         $row =~ s/\0//g;
43         print OUT $row;
44         $maybecomma = ",";
45     }
46
47     $row = "\n";
48     $row =~ s/\0//g;
49     print OUT $row;
50 }
51
52 close(OUT);
53 $dbh->disconnect;
54
55 exit 0;
This page took 0.129205 seconds and 5 git commands to generate.