#! /usr/local/bin/perl -w
$ip = "$ARGV[0]";
$rw = "$ARGV[1]";
$snmpg = "/usr/local/bin/snmpbulkget -v2c -Cn1 -Cn2 -Os -c $rw";
$snmpw = "/usr/local/bin/snmpwalk -Os -c $rw";
$syst=`$snmpg $ip system sysName sysObjectID`;
sysDescr.0 = STRING: Cisco Internetwork Operating System Software
IOS (tm) 7200 Software (C7200-JK9O3S-M), Version 12.3(22), RELEASE SOFTWARE (fc2)
Technical Support:
Cisco - Shortcut
Copyright (c) 1986-2007 by cisco Systems, Inc.
Compiled Wed 24-Jan-07 2
sysObjectID.0 = OID: enterprises.9.1.222
sysUpTime.0 = Timeticks: (122783188) 14 days, 5:03:51.88
sysContact.0 = STRING: 1265108
sysName.0 = STRING: nameoftherouter
sysLocation.0 = STRING: someplace, ny
sysServices.0 = INTEGER: 78
sysORLastChange.0 = Timeticks: (0) 0:00:00.00
ifNumber.0 = INTEGER: 10
ifIndex.1 = INTEGER: 1
ifIndex.2 = INTEGER: 2
In ksh to get the Version number and hostname I would do something like
vers=`echo "$syst" | grep -i version | sed 's/.*ersion //' | cut -d"," -f1`
hnam=`echo "$syst" | grep sysName | head -1 | sed 's/.*RING: //' | cut -d"."
-f1`
what is perls equivalent ?