#!/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/spwatch.out'; use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; $sth = $dbh->prepare("SELECT m.name FROM printers p, ". "machine m WHERE p.type = 'SAP' AND p.mach_id = ". "m.mach_id ORDER BY m.name") || exit $MR_DBMS_ERR; $sth->execute || exit $MR_DBMS_ERR; umask 022; open(OUT, ">$outfile") || exit $MR_OCONFIG; print OUT "# This File is automatically generated by Moira. Do not edit.\n"; while (($hostname) = $sth->fetchrow_array) { next if $hostname eq "[NONE]"; $row = "$hostname\n"; $row =~ s/\0//g; print OUT $row; } close OUT; exit 0;