From: Tim Greer Date: 2009-03-02T06:23:56+09:00 Subject: Re: Error when running script Brad Winborg wrote: > This is the script, it's intent is to read all Error logs.txt files in > a directory or just the text files that are listed. Find all the lines > that contain the word "error" and all the lines that contain the word > "warning" display a count of each word. Additionally it should create > report that tells how many times the two words appear every ten min, > for the duration of the error logs. > > my_path = "D:\My Documents\\Replicon\\log_file_20090221_041817.txt" > > warning = 0 > error = 0 > > d = Dir.new(my_path) > d.each do |fl| > unless fl == '.' or fl == '..' then > puts my_path + fl > File.open(my_path + fl, "r").each do |line| > if line =~ /error/ then > error += 1 > elsif line =~ /warning/ then > warning += 1 > end > end > > end > end > puts warning.to_s > puts error.to_s > > > Here is the errors I receive when I run it. > > Not a directory - D:\My > Documents\Replicon\log_file_20090221_041817.txt\ D:/My > Documents/Replicon/ErrorCount.rb:6:in `initialize' Press ENTER to > close the window... > Looks like you tried to open a file as a directory: D:\My Documents\Replicon\log_file_20090221_041817.txt The path looks to be: D:\My Documents\Replicon\ And the file in that path: log_file_20090221_041817.txt -- Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc. Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers and Custom Hosting. 24/7 support, 30 day guarantee, secure servers. Industry's most experienced staff! -- Web Hosting With Muscle!