]> andersk Git - moira.git/commitdiff
Add sapprint DCM for pushing list of SAP printers to windsurf
authormwhitson <mwhitson>
Fri, 17 Sep 1999 21:25:23 +0000 (21:25 +0000)
committermwhitson <mwhitson>
Fri, 17 Sep 1999 21:25:23 +0000 (21:25 +0000)
gen/Makefile.in
gen/sapprint.gen [new file with mode: 0755]
gen/sapprint.sh [new file with mode: 0755]

index 2eae800cb107f6622d6bd8020ace4b4fe2014ed5..71b30e4893e62eb4fc07f9b862be66261efb1fa9 100644 (file)
@@ -38,7 +38,8 @@ GDSS_TARGET=warehouse.gen
 TARGET=        boot.gen hesiod.gen nfs.gen mailhub.gen pobox.gen hosts.gen \
        print.gen printng.gen network.gen directory.gen ndb.gen @GDSS_TARGET@
 
-SCRIPTS=boot.sh hesiod.sh mailhub.sh nfs.sh null.sh print.sh warehouse.sh
+SCRIPTS=boot.sh hesiod.sh mailhub.sh nfs.sh null.sh print.sh \
+       sapprint.gen sapprint.sh warehouse.sh
 
 .SUFFIXES: .pc
 
diff --git a/gen/sapprint.gen b/gen/sapprint.gen
new file mode 100755 (executable)
index 0000000..6d6f73a
--- /dev/null
@@ -0,0 +1,37 @@
+#!/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;
diff --git a/gen/sapprint.sh b/gen/sapprint.sh
new file mode 100755 (executable)
index 0000000..5605ef6
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh
+# $Id$
+
+# The following exit codes are defined and MUST BE CONSISTENT with the
+# error codes the library uses:
+MR_MISSINGFILE=47836473
+
+PATH=/bin
+OUTFILE=/var/tmp/sapprint.out
+
+# Alert if the output file doesn't exist
+test -r $OUTFILE || exit $MR_MISSINGFILE
+
+# Set the perms usefully
+chown root $OUTFILE
+chgrp 0 $OUTFILE
+chmod 644 $OUTFILE
+
+# cleanup
+test -f $0 && rm -f $0
+
+exit 0
This page took 0.040226 seconds and 5 git commands to generate.