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

Discussion in 'Ruby' started by jackster the jackle, Jan 11, 2008.

  1. 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-forum.com/.
     
    jackster the jackle, Jan 11, 2008
    #1
    1. Advertising

  2. 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
     
    Stefano Crocco, Jan 11, 2008
    #2
    1. Advertising

  3. 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-forum.com/.
     
    jackster the jackle, Jan 11, 2008
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Big Bill
    Replies:
    7
    Views:
    441
    Big Bill
    May 7, 2004
  2. Mathias Waack

    squeeze and package imports

    Mathias Waack, Sep 25, 2003, in forum: Python
    Replies:
    2
    Views:
    289
    Mathias Waack
    Sep 27, 2003
  3. arnuld

    K&R2 section 2.8 (exercise 2.4) "squeeze"

    arnuld, Mar 13, 2007, in forum: C Programming
    Replies:
    5
    Views:
    478
    Barry Schwarz
    Mar 14, 2007
  4. luser-ex-troll

    META: relax topicality to squeeze the spam?

    luser-ex-troll, Mar 14, 2009, in forum: C Programming
    Replies:
    6
    Views:
    889
    luser-ex-troll
    Mar 17, 2009
  5. sara

    squeeze function

    sara, Oct 19, 2009, in forum: C++
    Replies:
    5
    Views:
    1,735
    Rolf Magnus
    Oct 19, 2009
Loading...

Share This Page