digcomp.pl revision a3128c1995310262648e575a9ff148d5741fd167
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# Copyright (C) 2004, 2007, 2012 Internet Systems Consortium, Inc. ("ISC")
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews# Copyright (C) 2000, 2001 Internet Software Consortium.
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews# Permission to use, copy, modify, and/or distribute this software for any
40f53fa8d9c6a4fc38c0014495e7a42b08f52481David Lawrence# purpose with or without fee is hereby granted, provided that the above
15a44745412679c30a6d022733925af70a38b715David Lawrence# copyright notice and this permission notice appear in all copies.
15a44745412679c30a6d022733925af70a38b715David Lawrence# THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
15a44745412679c30a6d022733925af70a38b715David Lawrence# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
15a44745412679c30a6d022733925af70a38b715David Lawrence# AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
15a44745412679c30a6d022733925af70a38b715David Lawrence# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
15a44745412679c30a6d022733925af70a38b715David Lawrence# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
15a44745412679c30a6d022733925af70a38b715David Lawrence# OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews# PERFORMANCE OF THIS SOFTWARE.
330705066b03f6ce0bc08a4bbfc5d2418038c68dBrian Wellington# $Id: digcomp.pl,v 1.14 2007/06/19 23:47:00 tbox Exp $
cd30495b0ca83a04d4d8f56728e38f93769aee98James Brister# Compare two files, each with the output from dig, for differences.
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews# Ignore "unimportant" differences, like ordering of NS lines, TTL's,
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrewsopen(FILE1, $file1) || die("open: $file1: $!\n");
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews if (/^;.+status:\s+(\S+).+$/) {
cd30495b0ca83a04d4d8f56728e38f93769aee98James Brister next if (/^;/);
63cef8bde8b92aeb30ccdcf21d4e44c9be9cc6e3Andreas Gustafsson if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff if ($entry{"$name ; $class.$type ; $value"} ne "") {
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews $line = $entry{"$name ; $class.$type ; $value"};
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("Duplicate entry in $file1:\n> $_\n< $line\n");
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence $entry{"$name ; $class.$type ; $value"} = $_;
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrewsopen(FILE2, $file2) || die("open: $file2: $!\n");
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews if (/^;.+status:\s+(\S+).+$/) {
6d12fdf96621801e80f3f4c2a8a569fe48766a20David Lawrence next if (/^;/);
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews if (/^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+(.+)$/) {
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews if (($name eq $firstname) && ($type eq "SOA")) {
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews if ($entry{"$name ; $class.$type ; $value"} ne "") {
6e49e91bd08778d7eae45a2229dcf41ed97cc636David Lawrence $entry{"$name ; $class.$type ; $value"} = "";
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("Only in $file2 (missing from $file1):\n")
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("> $_\n");
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("Only in $file1 (missing from $file2):\n")
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("< $entry{$key}\n");
419590499823ce15b5d2ad4fe71eaf04bd5a86c0Michael Graff print("< status: $rcode1\n");
db725ebe2b5d913949246b02573df01bd29f5412Mark Andrews print("> status: $rcode2\n");