Forum: Ruby on Rails File Auditing with rails - File I/O issue

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Brian C. (Guest)
on 2006-03-17 00:32
(Received via mailing list)
Hey Folks,
I've written a script to generate a list of all files on a machine,
then zip the results.  I'm going to stick a web front end on it, and use
it to audit some file servers. The problem is that the ZIP
compression/decompression isn't working,
but its not what you might think.  The script completes, but seems to
not actually write anything.

Here is a short version that only looks at the C:/temp drive.  You can
change this at the top.

---Start Code Here--
require 'find'
require 'csv'
require 'zlib'
tempfile = "temp.csv"
outfile  = ""
dirname = "c:/temp"
# Prepare comma-delimited file for writing
CSV::Writer.generate(,"w+"), ',') do |csv|
      Find.find(dirname) do |f|
          csv << [File.dirname(f), File.basename(f), File.mtime(f).to_s]
# TEST: View the tempfile to make sure it has data.
#  This prints nothing, but the file DOES have info after
# the script completes.  Maybe the file isn't written at this point?
p do |gz|
  gz <<
end {|gz|
# The ZIP file can't be extracted with WINZIP.  No idea why, but since
# I'll be using another RUBY script for extraction, im not sure that I

Brian C.
Chris H. (Guest)
on 2006-03-17 01:30
(Received via mailing list)
I think you might want to try

outfile = "out.gz"
... do |gz|

also, gzip != zip hence why winzip can't do anything with the resulting
gzipped file.  I wouldn't know if winzip supports gzip compression or
the extension for a gzipped file is typically .gz.

This topic is locked and can not be replied to.