source: trunk/third/moira/gen/sapprint.gen @ 25198

Revision 25198, 1.0 KB checked in by jdreed, 13 years ago (diff)
In moira: * Snapshot moira@r4042 (6/28/11) * Update version number to include moira revision number
  • Property svn:executable set to *
Line 
1#!/moira/bin/perl -Tw
2
3# $Id: sapprint.gen 4030 2011-03-04 21:01:14Z zacheiss $
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/sapprint.out';
11
12use DBI;
13
14$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
15  || exit $MR_DBMS_ERR;
16
17$sth = $dbh->prepare("SELECT p.name, p.hwtype, p.location, p.duplexname, p.rp, m.name ".
18                     "FROM printers p, machine m ".
19                     "WHERE p.rm=m.mach_id AND p.type='SAP' AND m.status !=3 AND " .
20                     "(p.status = 1 OR p.status = 2)")
21  || exit $MR_DBMS_ERR;
22
23$sth->execute || exit $MR_DBMS_ERR;
24
25umask 022;
26open(OUT, ">$outfile") || exit $MR_OCONFIG;
27
28while (($name, $hwtype, $location, $duplexname, $rp, $rm) =
29       $sth->fetchrow_array) {
30  $row = "$name:$hwtype $location:$duplexname:rp=$rp:rm=$rm\n";
31  $row .= "$duplexname:$name duplex queue:$duplexname:rp=$duplexname:rm=$rm\n"
32    unless ($duplexname eq "\0");
33  $row =~ s/\0//g;
34  print OUT $row;
35}
36
37close OUT;
38exit 0;
Note: See TracBrowser for help on using the repository browser.