title: convert and print a command output string to hash object
body: <p>i have a output of command stored in a string variable.
  i am trying to convert this into a hash object in ruby script.</p>
  
  <p>Here is the command output:</p>
  
  <pre><code>#lldptool get-tlv -n -i p2p1
  Chassis ID TLV
              MAC: 00:xx:xx:xx:xx:xx
      Port ID TLV
              Ifname: Ethernet1/3
  
      System Capabilities TLV
              System capabilities:  Bridge, Router
              Enabled capabilities: Bridge
  </code></pre>
  
  <p>so i want the final result to be of this format with {key:value} pairs.</p>
  
  <pre><code>{"Chassis ID TLV”=&gt;"00:xx:xx:xx:xx:xx", "Port ID TLV”=&gt;“Ethernet1/3”, "System Capabilities TLV"=&gt;{"System capabilities"=&gt;"Bridge, Router", "Enabled capabilities"=&gt;"Bridge"} }
  </code></pre>
  
  <p>Here is what i tried </p>
  
  <pre><code>lldp_hash = {
      # LLDP Name    Numeric value
      'chassisID'    =&gt; '1',
      'portID'       =&gt; '2',
      'System Capabilities TLV' =&gt; '3'
    }
  
  x = `lldptool get-tlv -n -i p2p1  2&gt;/dev/null`
  x = x.split("\n")
  puts x
  </code></pre>
  
  <p>I am not figuring a way to assign the keys to the values present in the string with which i can print the above desired format of hash.
  can someone provide some help over here.</p>