I am attempting to right a small utility that checks one file against
an automated snapshot of itself in a different location to make sure
that they are the same. I have not had any luck doing this and thought
I would present this to the group to see if you can help me out.
So far when I execute my code everything that is not an actual file
("." and "..") shows as OK but, anything else shows as not equal.
I have tried this using several different things like File1.size ==
File2.size and also what you see in the code listed below. Neither
seem to give me a result showing that these files are equal.
If I were to look in windows explore at these 2 files and look at the
file sizes, they both look identical so I am not sure what it is that
*.size is looking at to show that they aren't the same size.
Can anyone advise me on how I can better implement this? Also how I
can get rid of the "." files in the directory
My code so far is as below:
require 'fileutils'
require 'ftools'
y = Dir.entries("\\\\C:\\BNADataFile\\")
z = Dir.entries("\\\\F\\BNADataFile\\.snapshot\\hourly.0\\")
y.each do |y|
z.each do |z|
if(FileUtils.uptodate?(y,z))
puts y + ": Snapshot Successful"
else
puts y + ": Not the same"
end
end
end
My results: (Not sure why ".." showed up so many times)
C:\Documents and Settings\lmcilwain\My Documents\scripts\work>ruby
check.rb
.: Not the same
.: Snapshot Successful
.: Snapshot Successful
.: Snapshot Successful
.: Snapshot Successful
.: Snapshot Successful
.: Snapshot Successful
.: Snapshot Successful
..: Snapshot Successful
backup: Not the same
Archived..cdb: Not the same
OPInc..cdb: Not the same
ArchivedAlt.cdb: Not the same
Alts.cdb: Not the same
event.log: Not the same