]> andersk Git - moira.git/blob - gen/spwatch.gen
6443f149aa7709b45104cd91ef30551fb4de6e3f
[moira.git] / gen / spwatch.gen
1 #!/moira/bin/perl -Tw
2 # $Id$
3 #
4 # The following exit codes are defined and MUST BE CONSISTENT with the
5 # error codes the library uses:
6 $MR_DBMS_ERR = 47836421;
7 $MR_OCONFIG = 47836460;
8
9 $outfile = '/moira/dcm/spwatch.out';
10
11 use DBI;
12
13 $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
14     || exit $MR_DBMS_ERR;
15
16 $sth = $dbh->prepare("SELECT p.name, m.name, p.location FROM printers p, ".
17                      "machine m WHERE p.type = 'SAP' AND p.mach_id = ".
18                      "m.mach_id ORDER BY p.name") || exit $MR_DBMS_ERR;
19
20 $sth->execute || exit $MR_DBMS_ERR;
21
22 umask 022;
23 open(OUT, ">$outfile") || exit $MR_OCONFIG;
24
25 while (($name, $hostname, $location) = $sth->fetchrow_array) {
26     next if $hostname eq "[NONE]";
27     $row = "$name\t$hostname\t$location\n";
28     $row =~ s/\0//g;
29     print OUT $row;
30 }
31
32 close OUT;
33 exit 0;
This page took 0.028904 seconds and 3 git commands to generate.