[1839] in Moira
longjobs dcm
daemon@ATHENA.MIT.EDU (Garry Zacheiss)
Wed Aug 1 15:12:07 2001
Message-Id: <200108011912.PAA17663@brad-majors.mit.edu>
To: moiradev@MIT.EDU
Date: Wed, 01 Aug 2001 15:12:05 -0400
From: Garry Zacheiss <zacheiss@MIT.EDU>
As requested by Bob, spits out a data file of all the groups
moira knows about for use by the longjobs servers.
Garry
Index: longjobs.gen
===================================================================
RCS file: longjobs.gen
diff -N longjobs.gen
--- /dev/null Wed Aug 1 12:43:32 2001
+++ longjobs.gen Wed Aug 1 14:59:05 2001
@@ -0,0 +1,55 @@
+#!/moira/bin/perl -Tw
+
+# $Id$
+
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# error codes the library uses:
+$MR_DBMS_ERR = 47836421;
+$MR_OCONFIG = 47836460;
+
+$outfile = '/moira/dcm/longjobs.out';
+
+use DBI;
+
+$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
+ || exit $MR_DBMS_ERR;
+
+$sth = $dbh->prepare("SELECT name FROM list WHERE grouplist = 1")
+ || exit $MR_DBMS_ERR;
+
+$sth->execute || exit $MR_DBMS_ERR;
+
+umask 022;
+open(OUT, ">$outfile") || exit $MR_OCONFIG;
+
+while ($name = $sth->fetchrow_array) {
+
+ $sth2 = $dbh->prepare("SELECT u.login FROM users u, imembers i, list l " .
+ "WHERE l.name = " . $dbh->quote($name) .
+ "AND l.list_id = i.list_id " .
+ "AND i.member_type = 'USER' " .
+ "AND i.member_id = u.users_id") || exit $MR_DBMS_ERR;
+
+ $sth2->execute || exit $MR_DBMS_ERR;
+
+ $row = "$name:";
+ $row =~ s/\0//g;
+ print OUT $row;
+ $maybecomma = "";
+
+ while ($member = $sth2->fetchrow_array) {
+ $row = "$maybecomma$member";
+ $row =~ s/\0//g;
+ print OUT $row;
+ $maybecomma = ",";
+ }
+
+ $row = "\n";
+ $row =~ s/\0//g;
+ print OUT $row;
+}
+
+close(OUT);
+$dbh->disconnect;
+
+exit 0;