]>
Commit | Line | Data |
---|---|---|
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 | ||
11 | use 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 | ||
23 | umask 022; | |
24 | open(OUT, ">$outfile") || exit $MR_OCONFIG; | |
25 | ||
26 | while (($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 | ||
33 | close(OUT); | |
34 | $dbh->disconnect; | |
35 | ||
36 | exit 0; |