[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

require "snmp" error in script

jackster the jackle

12/5/2007 9:57:00 PM

I am trying to require "snmp" in a basic script to poll some networking
devices and I'm getting the following error:

/snmp.rb:4: uninitialized constant SNMP (NameError)
from ./snmp.rb:3:in `require'
from ./snmp.rb:3

I successfully installed the following 3 gems:
snmp (1.0.1)
snmpscan (0.1)
snmptop (0.0.1)

Here is the code in snmp.rb:

#!/usr/local/bin/ruby
require "snmp"
SNMP::Mangager.open(:Host => "172.30.152.1") do |m|
response = m.get(["syslocation.0", "sysuptime.0"])
response.each_varbind { |vb| puts "#{vb.name}: #{vb.value}" }
end

It looks to me like ruby isn't finding the snmp gem that I installed?
Any ideas would be appreciated.

thanks
jackster
--
Posted via http://www.ruby-....

1 Answer

Klodus Klodus

12/5/2007 11:23:00 PM

0

add line

require "rubygems"

at the top

klodus

jackster the jackle wrote:
> I am trying to require "snmp" in a basic script to poll some networking
> devices and I'm getting the following error:
>
> ./snmp.rb:4: uninitialized constant SNMP (NameError)
> from ./snmp.rb:3:in `require'
> from ./snmp.rb:3
>
> I successfully installed the following 3 gems:
> snmp (1.0.1)
> snmpscan (0.1)
> snmptop (0.0.1)
>
> Here is the code in snmp.rb:
>
> #!/usr/local/bin/ruby
> require "snmp"
> SNMP::Mangager.open(:Host => "172.30.152.1") do |m|
> response = m.get(["syslocation.0", "sysuptime.0"])
> response.each_varbind { |vb| puts "#{vb.name}: #{vb.value}" }
> end
>
> It looks to me like ruby isn't finding the snmp gem that I installed?
> Any ideas would be appreciated.
>
> thanks
> jackster

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