[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

comp.lang.ruby

Trying to squeeze a variable in here => ...

jackster the jackle

1/11/2008 8:42:00 PM

Hi Ruby...

I have an SNMP command that I'm using which works fine in my script:

There is a static portion that needs to be changed so I can feed in the
variable and it's a bit tricky. I have tried every combination of " "
and ' ' that I can think of and nothing works.
Here is the line of code that works:

response = m.get (["ifInOctets.1"])

The number "1" in the above piece of code needs to be changed to a
variable.

Any ideas on how to squeeze a variable in there?

thanks

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

2 Answers

Stefano Crocco

1/11/2008 9:17:00 PM

0

Alle venerd=C3=AC 11 gennaio 2008, jackster the jackle ha scritto:
> Hi Ruby...
>
> I have an SNMP command that I'm using which works fine in my script:
>
> There is a static portion that needs to be changed so I can feed in the
> variable and it's a bit tricky. I have tried every combination of " "
> and ' ' that I can think of and nothing works.
> Here is the line of code that works:
>
> response =3D m.get (["ifInOctets.1"])
>
> The number "1" in the above piece of code needs to be changed to a
> variable.
>
> Any ideas on how to squeeze a variable in there?
>
> thanks
>
> jackster.mobi

Use string interpolation:

response =3D m.get(["ifInOctets.#{number}])

Stefano

jackster the jackle

1/11/2008 10:13:00 PM

0

Stefano Crocco wrote:
> Alle venerdì 11 gennaio 2008, jackster the jackle ha scritto:
>>
>> The number "1" in the above piece of code needs to be changed to a
>> variable.
>>
>> Any ideas on how to squeeze a variable in there?
>>
>> thanks
>>
>> jackster.mobi
>
> Use string interpolation:
>
> response = m.get(["ifInOctets.#{number}])
>
> Stefano

that did the trick...thanks alot for the help on that Stefano

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