LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-15-2008, 03:00 PM   #1
lmcilwain
Member
 
Registered: Dec 2003
Location: Maryland
Distribution: Fedora, Ubuntu, Centos, FreeBSD
Posts: 390

Rep: Reputation: 31
[Ruby] FileUtils and Ftools


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 you to see if you can help me out.

So far when I execute my code everything that is not an actual file shows as equal but, anything else that is not shown as a file shows as not equal. Now I have tried this using several different utilities.

1. y.size == z.size

and also what you see in the code listed below. Neither seem to give me a result showing that these files are equal.

Can anyone advise me on how I can better implement this? Also how I can get rid of the "." files in the directory ~

Code:
require 'fileutils'
require 'ftools'

y = Dir.entries("\\\\corporate\\finance\\Private\\BNADataFile\\")
z = Dir.entries("\\\\corporate\\finance\\Private\\BNADataFile\\.snapshot\\hourly.0\\")

y.each do |y|
    z.each do |z|
        if(FileUtils.uptodate?(y,z))
            puts y + ": Same"
        else
            puts y + ": Not the same"
        end
    end
end

Code:
C:\Documents and Settings\lmcilwain\My Documents\scripts\work>ruby check.rb
.: Snapshot not the same, please address
.: 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

C:\Documents and Settings\lmcilwain\My Documents\scripts\work>
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Ruby SDL/ Ruby OpenGL tutorials/reference? LinuxNoob75 Programming 0 12-30-2007 12:47 PM
[Ruby] Tar'ing or Zip'ing with ruby script lmcilwain Programming 2 01-19-2007 06:56 PM
[Ruby] Installing FileUtils Module lmcilwain Programming 1 01-16-2007 03:12 AM
fileutils problem xquizit Linux From Scratch 2 04-30-2003 09:42 PM
Fileutils... Chijtska Linux From Scratch 1 02-13-2002 09:27 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:13 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration