Ruby scripting - I am just starting to learn Ruby and I wanted to know
if anyone out there knows it well. I am trying to do a project and I
have run into a problem.
I have an executable file that when run creates (n) number of error
logs. So from a command prompt you run the ,exe with with (n) being the
number of logs you wish to create. We will make n =10. Then using ruby
create a program that will search through those 10 error logs and find
and display how many times the word error is found and how many times
the word warning is found. Then Produce a report showing the number of
error and warning log messages for 10-minute over the entire length of
time represented by the generated log files.
On Thu, Feb 26, 2009 at 12:34 PM, Brad W.
[email protected] wrote:
error and warning log messages for 10-minute over the entire length of
time represented by the generated log files.
sounds rather like a homework assignment …
what have you tried so far?
Brad W. wrote:
Ruby scripting - I am just starting to learn Ruby and I wanted to know
if anyone out there knows it well. I am trying to do a project and I
have run into a problem.
I have an executable file that when run creates (n) number of error
logs. So from a command prompt you run the ,exe with with (n) being the
number of logs you wish to create. We will make n =10. Then using ruby
create a program that will search through those 10 error logs and find
and display how many times the word error is found and how many times
the word warning is found. Then Produce a report showing the number of
error and warning log messages for 10-minute over the entire length of
time represented by the generated log files.
Start by reading a good Ruby primer -
Programming Ruby: The Pragmatic Programmer's Guide is browsable online for
free, or there are many to choose from any buy. Type in and run the
examples. Then start writing your own code, and when you get stuck at a
particular point, you will be able to ask a more specific question.
For example: if you get stuck at iterating over all the files in a
directory, look at Dir.glob, which is also callable as Dir[]
Dir["foo.*"].each do |fn|
puts fn
end
Also, browse the archives of this list. An almost identical question to
yours (about counting flight arrivals and departures) was asked a day or
two ago.
Good luck,
Brian.
pat eyler wrote:
On Thu, Feb 26, 2009 at 12:34 PM, Brad W.
[email protected] wrote:
error and warning log messages for 10-minute �over the entire length of
time represented by the generated log files.
sounds rather like a homework assignment …
what have you tried so far?
You are fairly close I am studying ruby and have never programed before
this is a test I found and wanted to try. I have attached what I have
and think it should work but I keep getting the following error
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.
C:\Documents and Settings\Brad>cd c:\ruby
C:\Ruby>ruby count.rb
count.rb:8:in initialize': No such file or directory - D:\My Documents\My Downl oads\Tezt\files (Errno::ENOENT) from count.rb:8:in
new’
from count.rb:8
C:\Ruby>
I have also used the same script with the error file name
log_file_20090221_095030.txt. I am just using one at this time.
On Thu, Feb 26, 2009 at 2:34 PM, Brad W.
[email protected] wrote:
I am just starting to learn Ruby and I wanted to know
if anyone out there knows it well.
Well, there is this one guy in Japan…