#!/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/sapprint.out'; use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; $sth = $dbh->prepare("SELECT p.name, p.hwtype, p.location, p.duplexname, p.rp, m.name ". "FROM printers p, machine m ". "WHERE p.rm=m.mach_id AND p.type='SAP'") || exit $MR_DBMS_ERR; $sth->execute || exit $MR_DBMS_ERR; umask 022; open(OUT, ">$outfile") || exit $MR_OCONFIG; while (($name, $hwtype, $location, $duplexname, $rp, $rm) = $sth->fetchrow_array) { $row = "$name:$hwtype $location:$duplexname:rp=$rp:rm=$rm\n"; $row .= "$duplexname:$name duplex queue:$duplexname:rp=$duplexname:rm=$rm\n" unless ($duplexname eq "\0"); $row =~ s/\0//g; print OUT $row; } close OUT; exit 0;