I am trying to make the transition from shell to perl.
My cheap code
#!/usr/local/bin/perl -w
#
use lib '/perl/arch';
use lib '/perl/lib';
#
open(IPL, "$ARGV[0]");
$commstrng = "$ARGV[1]";
#
while($bulls = <IPL>) {
chomp($bulls);
@Sysob=`/usr/local/bin/snmpwalk -c $commstrng $bulls system 2>/dev/null`;
@xray = split(/,/,$Sysob[1]);
print "$xray[1]\n";
}
The output
SNMPv2-MIB::sysDescr.0 = STRING: Cisco Internetwork Operating System Software
IOS (tm) C3550 Software (C3550-I5K2L2Q3-M), Version 12.1(13)EA1c, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2003 by cisco Systems, Inc.
Compiled Tue 24-Jun-03 19:30 by yenanh
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.9.1.367
SNMPv2-MIB::sysUpTime.0 = Timeticks: (1781498469) 206 days, 4:36:24.69
SNMPv2-MIB::sysContact.0 = STRING:xxxx
SNMPv2-MIB::sysName.0 = STRING: xxxxxxx
SNMPv2-MIB::sysLocation.0 = STRING: 6xxxxxx, CA 92660
SNMPv2-MIB::sysServices.0 = INTEGER: 6
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
How many lines in this walk ?
> snmpwalk -c xxxxxx! xxxxx system | wc -l
11
The problem is that response to the ISO system variable will not always be in the same format or the same length(in lines). Im not sure how to deal with that.
I know I can use split, index and rindex to extract the data I need .. but the output may be junk depending upon the initial result.
@xray = split(/,/,$Sysob[1]);
print "$xray[1]\n"; .... may not always be
" Version 12.1(13)EA1c"
Thanks for helping this perl rookie.
My cheap code
#!/usr/local/bin/perl -w
#
use lib '/perl/arch';
use lib '/perl/lib';
#
open(IPL, "$ARGV[0]");
$commstrng = "$ARGV[1]";
#
while($bulls = <IPL>) {
chomp($bulls);
@Sysob=`/usr/local/bin/snmpwalk -c $commstrng $bulls system 2>/dev/null`;
@xray = split(/,/,$Sysob[1]);
print "$xray[1]\n";
}
The output
SNMPv2-MIB::sysDescr.0 = STRING: Cisco Internetwork Operating System Software
IOS (tm) C3550 Software (C3550-I5K2L2Q3-M), Version 12.1(13)EA1c, RELEASE SOFTWARE (fc1)
Copyright (c) 1986-2003 by cisco Systems, Inc.
Compiled Tue 24-Jun-03 19:30 by yenanh
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.9.1.367
SNMPv2-MIB::sysUpTime.0 = Timeticks: (1781498469) 206 days, 4:36:24.69
SNMPv2-MIB::sysContact.0 = STRING:xxxx
SNMPv2-MIB::sysName.0 = STRING: xxxxxxx
SNMPv2-MIB::sysLocation.0 = STRING: 6xxxxxx, CA 92660
SNMPv2-MIB::sysServices.0 = INTEGER: 6
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
How many lines in this walk ?
> snmpwalk -c xxxxxx! xxxxx system | wc -l
11
The problem is that response to the ISO system variable will not always be in the same format or the same length(in lines). Im not sure how to deal with that.
I know I can use split, index and rindex to extract the data I need .. but the output may be junk depending upon the initial result.
@xray = split(/,/,$Sysob[1]);
print "$xray[1]\n"; .... may not always be
" Version 12.1(13)EA1c"
Thanks for helping this perl rookie.