#!/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/ip-billing.out'; use DBI; $dbh = DBI->connect("dbi:Oracle:moira", "moira", "moira") || exit $MR_DBMS_ERR; $sth = $dbh->prepare("SELECT m.address, m.location, m.account_number, " . "m.name, m.contact FROM machine m, subnet s WHERE " . "m.status = 1 and m.snet_id = s.snet_id " . "AND s.status = 1") || exit $MR_DBMS_ERR; $sth->execute || exit $MR_DBMS_ERR; umask 022; open(OUT, ">$outfile") || exit $MR_OCONFIG; while (($address, $location, $accountnumber, $hostname, $contact) = $sth->fetchrow_array) { $row= "$address\t$location\t$accountnumber\t$hostname\t$contact\n"; $row =~ s/\0//g; print OUT $row; } close(OUT); $dbh->disconnect; exit 0;