cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3051
Views
0
Helpful
2
Replies

TcL Based File Diff report

Cory Anderson
Level 1
Level 1

I'm looking to create a report on differences between files using TcL.  One example is comparing a current configuration against a "baseline" configuration and reporting differences.  I have this, which will return a 1 if there's a difference, or a zero if there's no difference, but I want to report the actual difference between the two files.

proc diffFileChunked {baseline current {chunksize 16384}} {
     set f1 [open $baseline]; fconfigure $f1 -translation binary
     set f2 [open $current]; fconfigure $f2 -translation binary
     while {1} {
          set d1 [read $f1 $chunksize]
          set d2 [read $f2 $chunksize]
          set diff [string compare $d1 $d2]
                    if {$diff != 0 || [eof $f1] || [eof $f2]} {
                              close $f1; close $f2
                              return $diff
                    }
        }
}

1 Accepted Solution

Accepted Solutions

Joe Clarke
Cisco Employee
Cisco Employee

There is a command in IOS that will show you the contextual diffs between any two text files.  Just run the command "show archive config differences old_file new_file".

View solution in original post

2 Replies 2

Joe Clarke
Cisco Employee
Cisco Employee

There is a command in IOS that will show you the contextual diffs between any two text files.  Just run the command "show archive config differences old_file new_file".

Thanks Joe!

I didn't realize I can pull files from an external source with that, but it works perfectly.