I've been struggling to come up with a solution for this, the goal is to organize the results into comma separated columns as we have to recable our entire datacenter from cat6 to cat6a.
$DBFILE output is access1a access1b ...
goal:
switch,switch-port,server,server-port
access1a,1,server6,eth0
access1a,2,server4,eth0
access1a,3,server1,eth0
how ever my current output is the following:
#!/bin/sh
DBFILE=$(cat /tmp/routers.all | awk -F: '{print $1}'| grep access)
for OUTPUT in $DBFILE
do
/usr/bin/snmpwalk -Os -c pass -v 2c $OUTPUT iso.0.8802.1.1.2.1.4.1.1.8.0 | tr -d "\"" | sed -r 's/ /./g' |awk -F. '{print "'"$OUTPUT"'"","$13","$22","}'
/usr/bin/snmpwalk -Os -c pass -v 2c $OUTPUT iso.0.8802.1.1.2.1.4.1.1.9.0 | tr -d "\"" | sed -r 's/ /./g' |awk -F. '{print "'"$OUTPUT"'"","$13","$17","}'
done
access1a,1,server6,
access1a,2,server4,
access1a,3,server1,
access1a,1,eth0,
access1a,2,eth0,
access1a,3,eth0,
I've tried many different variations of arrays and for loops and either i only get the very last query or no success at all, i figured i'd ask as i can't seem to find methods to accomplish the following.