]> andersk Git - moira.git/blame - gen/ip-billing.gen
Add support for get_host_by_account_number query.
[moira.git] / gen / ip-billing.gen
CommitLineData
a1077ef2 1#!/moira/bin/perl
2
3# $Id$
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/ip-billing.out';
10
11use DBI;
12
13$dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira")
14 || exit $MR_DBMS_ERR;
15
16$sth = $dbh->prepare("SELECT m.address, m.location, m.account_number, " .
17 "m.name, m.contact FROM machine m, subnet s WHERE " .
18 "m.status = 1 and m.snet_id = s.snet_id " .
19 "AND s.status = 1") || exit $MR_DBMS_ERR;
20
21$sth->execute || exit $MR_DBMS_ERR;
22
23umask 022;
24open(OUT, ">$outfile") || exit $MR_OCONFIG;
25
26while (($address, $location, $accountnumber, $hostname, $contact) =
27 $sth->fetchrow_array) {
28 $row= "$address\t$location\t$accountnumber\t$hostname\t$contact\n";
29 $row =~ s/\0//g;
30 print OUT $row;
31}
32
33close(OUT);
34$dbh->disconnect;
35
36exit 0;
This page took 0.255311 seconds and 5 git commands to generate.