Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Announcements

Welcome to Cisco Support Community. We would love to have your feedback.

For an introduction to the new site, click here. And see here for current known issues.

New Member

TcL Based File Diff report

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
Cisco Employee

There is a command in IOS

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".

2 REPLIES
Cisco Employee

There is a command in IOS

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".

New Member

Thanks Joe!

Thanks Joe!

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

234
Views
0
Helpful
2
Replies
CreatePlease login to create content