# Getting SNMP data in variable instead of using puts

**URL:** <https://www.ruby-forum.com/t/getting-snmp-data-in-variable-instead-of-using-puts/128330>\
**Category:** Ruby\
**Created:** [February 6, 2008, 8:35pm UTC](https://www.ruby-forum.com/t/getting-snmp-data-in-variable-instead-of-using-puts/128330 "2008-02-06T20:35:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 6, 2008, 8:35pm UTC](https://www.ruby-forum.com/t/getting-snmp-data-in-variable-instead-of-using-puts/128330/1 "2008-02-06T20:35:27Z")

</div>

I’m trying to access my variable directly here rather than using puts to  
print it out. Can anyone tell me the easiest way to access it from the  
variable?

ipadd = ARGV[0]  
columns = [“ifDescr”]  
SNMP::Manager.open(:Host =\> ipadd, :Community =\> “877pricelineHOBO” ) do  
|m|  
m.walk(columns) { |row| puts row.join("\t") }  
end

thanks

jackster

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 7, 2008, 1:47am UTC](https://www.ruby-forum.com/t/getting-snmp-data-in-variable-instead-of-using-puts/128330/2 "2008-02-07T01:47:44Z")

</div>

On Feb 6, 2008 1:35 PM, jackster the jackle [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> I’m trying to access my variable directly here rather than using puts to  
> print it out. Can anyone tell me the easiest way to access it from the  
> variable?

Can’t test right now because I don’t have a device/system using SNMP  
handy, but, thinking it’s simply a scoping issue…

> ipadd = ARGV[0]  
> columns = [“ifDescr”]

ifDescr = []

> SNMP::Manager.open(:Host =\> ipadd, :Community =\> “877pricelineHOBO” ) do  
> |m|

```
  m.walk(columns) { |row| ifDescr << row.join("\t") }

```

> end

puts ifDescr

Todd

---

<div class="post-metadata">

**Author:** ![jackster](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@jackster](https://www.ruby-forum.com/u/jackster)\
**Post date:** [February 7, 2008, 10:47pm UTC](https://www.ruby-forum.com/t/getting-snmp-data-in-variable-instead-of-using-puts/128330/3 "2008-02-07T22:47:20Z")

</div>

Thanks alot Todd…I’m in good shape…

jackster

Todd B. wrote:

> On Feb 6, 2008 1:35 PM, jackster the jackle [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > I’m trying to access my variable directly here rather than using puts to  
> > print it out. Can anyone tell me the easiest way to access it from the  
> > variable?
> 
> Can’t test right now because I don’t have a device/system using SNMP  
> handy, but, thinking it’s simply a scoping issue…
> 
> > ipadd = ARGV[0]  
> > columns = [“ifDescr”]
> 
> ifDescr = []
> 
> > SNMP::Manager.open(:Host =\> ipadd, :Community =\> “877pricelineHOBO” ) do  
> > |m|
> 
> ```
> m.walk(columns) { |row| ifDescr << row.join("\t") }
> 
> ```
> 
> > end
> 
> puts ifDescr
> 
> Todd
