Hi,<br>I used to use perl a bit but I am very rusty. I am trying to walk the ifIndex portion of a cisco switch so that I can either get the last index number or build an array of index numbers to use for queries.<br><br>I have tried using a get_request in a loop until I get an error but there is a break in list. When I do an snmpwalk I see index numbers from 1-105 and 154-224 with the break in the middle so my script stops at 105 indicating that it is the last. If I use get_next_request it does not error out. Can anyone guide my failing logic?<br>
<br>---------<br><br><br>
<br>#!/usr/bin/perl -w<br><br>use Net::SNMP;<br>my $OID_vLanID = &#39;1.3.6.1.2.1.2.2.1.1.&#39;;<br><br>my ($session, $error) = Net::SNMP-&gt;session(<br>      -hostname  =&gt; &#39;SWITCH_IP&#39;,<br>      -community =&gt; &#39;public&#39;<br>
   );<br><br>if (!defined $session) {<br>      printf &quot;ERROR: %s.\n&quot;, $error;<br>      exit 1;<br>   }<br>$foundLast = 0;<br>$item = 1;<br>while ($foundLast != 1)<br>{<br>        $getValue = &quot;$OID_vLanID&quot; . &quot;$item&quot;;<br>
        $result = $session-&gt;get_request(-varbindlist =&gt; [ $getValue ],);<br>        if (!defined $result)<br>        {<br>                $item--;<br>                printf &quot;ITEM is $item-- -- ERROR: %s.\n&quot;, $session-&gt;error();<br>
                $foundLast = 1;<br>                $session-&gt;close();<br>        }<br>        else<br>        {<br>        $item++;<br>        }<br>}<br><br>print &quot;Total: $item\n&quot;;<br>   $session-&gt;close();<br>
<br>exit 0;<br>