Ruby scripting

B

Brad Winborg

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.
 
P

pat eyler

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 =3D10. 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 =A0over the entire length of
time represented by the generated log files.


sounds rather like a homework assignment ....

what have you tried so far?




--=20
thanks,
-pate
 
B

Brian Candler

Brad said:
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 -
http://www.ruby-doc.org/docs/ProgrammingRuby/ 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.
 
B

Brad Winborg

pat said:
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.

Attachments:
http://www.ruby-forum.com/attachment/3355/count.rb
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,142
Latest member
arinsharma
Top