in reply to Need help with SNMP script
To make the existing code work you need to skip the lines that don't have enough elements for the split to return for your comparisons:
while (<SNMP>) { next if /^#|^\s*$/; ...
or try this to use a regular expression instead;
while (<DATA>) { print "$1\n" if /^snmpmanager\s+(\d+\.\d+\.\d+\.\d+)\s+;\s+communi +tyname/; } __DATA__ #test file #example: snmpmanager 10.52.37.99 ; communityname public
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Need help with SNMP script
by Xandrex (Initiate) on Oct 04, 2011 at 18:55 UTC | |
by Lotus1 (Vicar) on Oct 04, 2011 at 19:32 UTC |