#!/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 = 4783640; $outfile = '/moira/dcm/mailhosts.out'; use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; $sth = $dbh->prepare("SELECT f.label, m.name ". "FROM filesys f, machine m, nfsphys p, serverhosts s ". "WHERE s.service='POSTOFFICE' AND s.mach_id=f.mach_id ". "AND f.mach_id=m.mach_id AND f.type='IMAP' ". "AND f.createflg!=0 AND f.mach_id=p.mach_id ". "AND f.phys_id=p.nfsphys_id ". "ORDER BY f.label") || exit $MR_DBMS_ERR; $sth->execute || exit $MR_DBMS_ERR; $tnow = localtime; umask 022; open(OUT, ">$outfile") || exit $MR_OCONFIG; print OUT "; MIT Network Host Table\n;\n"; print OUT "; \t\$" . "Author:" . " \$\n"; print OUT "; \t\$" . "Date:" . " \$\n"; print OUT "; \t\$" . "Revision:" . " \$\n"; print OUT "; Host table generated by Moira at $tnow\n;\n"; while (($label, $name) = $sth->fetchrow_array) { $label =~ s/\.po$//; $label =~ tr/a-z/A-Z/; $name =~ tr/a-z/A-Z/; if (16 - length($label) > 8) { $sp = "\t"; } else { $sp = ""; } $row = "$label$sp\tIN\tCNAME\t$name.\n"; $row =~ s/\0//g;; print OUT $row; } close(OUT); $dbh->disconnect; exit 0;