Gem win32-eventlog v0.5.2 on Ruby 1.9.1

1.Requirement: Read the latest lines of the Windows Application Event
Viewer to verify deployment status executions.
2. Environment: Ruby 1.9.1 On Windows
                win32-eventlog (0.5.2)
                windows-api (0.4.0)
                windows-pr (1.1.3)
3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
but on ruby 1.9.1 they don't. I know the String management has changed
on Ruby 1.9.1 and above.

4. Exception Details.
   C:/Ruby191/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:14:in
`[]': invalid byte sequence in US-ASCII (ArgumentError)
        from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:14:in
`nstrip'
        from
C:/Ruby191/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:613:in
`read'
        from bw_logutil.rb:49:in `read_event_log'
        from bw_logutil.rb:97:in `block in <main>'
        from bw_logutil.rb:96:in `each'
        from bw_logutil.rb:96:in `<main>'
5. Source of Information :
   http://raa.ruby-lang.org/project/win32-eventlog/
6. Tried Solutions. Tried to use WMI but there is no way to filter the
latest results.

Could someone help me with this.

···

--
Posted via http://www.ruby-forum.com/.

Please try Ruby 1.9.2-p136.

Also, report the issue back to win32utils developers:

http://rubyforge.org/projects/win32utils

Who will tell you the same thing, try Ruby 1.9.2

···

On Feb 2, 1:51 pm, "Luis M." <lmayorga1...@gmail.com> wrote:

3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
but on ruby 1.9.1 they don't. I know the String management has changed
on Ruby 1.9.1 and above.

--
Luis Lavena

Luis Lavena wrote in post #979202:

···

On Feb 2, 1:51pm, "Luis M." <lmayorga1...@gmail.com> wrote:

3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
but on ruby 1.9.1 they don't. I know the String management has changed
on Ruby 1.9.1 and above.

Please try Ruby 1.9.2-p136.

Also, report the issue back to win32utils developers:

http://rubyforge.org/projects/win32utils

Who will tell you the same thing, try Ruby 1.9.2

I will try this new version.

--
Posted via http://www.ruby-forum.com/.

Luis Lavena wrote in post #979202:

3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
but on ruby 1.9.1 they don't. I know the String management has changed
on Ruby 1.9.1 and above.

Please try Ruby 1.9.2-p136.

Also, report the issue back to win32utils developers:

http://rubyforge.org/projects/win32utils

Who will tell you the same thing, try Ruby 1.9.2

SOLUTION!!!!

Finally, I modified the eventlog.rb with the following lines:

val = buf[56..-1] #--

               if !val.ascii_only?
                val.force_encoding($>.external_encoding ||
Encoding.default_external)
               end
               event_source = val.nstrip
               #puts event_source

               newval = buf[56 + event_source.length + 1..-1]

               if !newval.ascii_only?
                newval.force_encoding($>.external_encoding ||
Encoding.default_external)
               end

#This is based on the help of this forum
#http://rubyforge.org/forum/forum.php?thread_id=49201&forum_id=319

Thank you Ruby Friends.

···

On Feb 2, 1:51pm, "Luis M." <lmayorga1...@gmail.com> wrote:

--
Posted via http://www.ruby-forum.com/.

Luis M. wrote in post #979203:

Luis Lavena wrote in post #979202:

3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
but on ruby 1.9.1 they don't. I know the String management has changed
on Ruby 1.9.1 and above.

Please try Ruby 1.9.2-p136.

Also, report the issue back to win32utils developers:

http://rubyforge.org/projects/win32utils

Who will tell you the same thing, try Ruby 1.9.2

I will try this new version.

I tried the new version Ruby 1.9.2, installing the win32-eventlog gem
but the same result.

C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:14:in
`[]': invalid byte sequence in US-ASCII (ArgumentError)
        from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:14:in
`nstrip'
        from
C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog.rb:613:in
`read'
        from bw_logutil.rb:50:in `read_event_log'
        from bw_logutil.rb:98:in `block in <main>'
        from bw_logutil.rb:97:in `each'
        from bw_logutil.rb:97:in `<main>'

···

On Feb 2, 1:51pm, "Luis M." <lmayorga1...@gmail.com> wrote:

--
Posted via http://www.ruby-forum.com/.

First your script needs to be in the same encoding that eventlog is
expecting.

As I mentioned, please report this error/bug to win32utils developers
in the provided link, they might be able to help you better.

···

On Feb 2, 2:40 pm, "Luis M." <lmayorga1...@gmail.com> wrote:

Luis M. wrote in post #979203:

> Luis Lavena wrote in post #979202:
>> On Feb 2, 1:51pm, "Luis M." <lmayorga1...@gmail.com> wrote:
>>> 3. Problem: On Ruby 1.8.7 my scripts using win32 evenlog api works fine
>>> but on ruby 1.9.1 they don't. I know the String management has changed
>>> on Ruby 1.9.1 and above.

>> Please try Ruby 1.9.2-p136.

>> Also, report the issue back to win32utils developers:

>>http://rubyforge.org/projects/win32utils

>> Who will tell you the same thing, try Ruby 1.9.2

> I will try this new version.

I tried the new version Ruby 1.9.2, installing the win32-eventlog gem
but the same result.

C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog .rb:14:in
`[]': invalid byte sequence in US-ASCII (ArgumentError)

--
Luis Lavena

Luis Lavena wrote in post #979214:

···

On Feb 2, 2:40pm, "Luis M." <lmayorga1...@gmail.com> wrote:

> Luis Lavena wrote in post #979202:

>> Who will tell you the same thing, try Ruby 1.9.2

> I will try this new version.

I tried the new version Ruby 1.9.2, installing the win32-eventlog gem
but the same result.

C:/Ruby192/lib/ruby/gems/1.9.1/gems/win32-eventlog-0.5.2/lib/win32/eventlog

.rb:14:in

`[]': invalid byte sequence in US-ASCII (ArgumentError)

First your script needs to be in the same encoding that eventlog is
expecting.

As I mentioned, please report this error/bug to win32utils developers
in the provided link, they might be able to help you better.

You mean adding at the top of the script the following line.

# encoding: UTF-8

--
Posted via http://www.ruby-forum.com/.