I'm trying to use the while read
command to create a comma separated table of names, routers, and IP addresses. It should then SSH through that series of routers with the router1 value, input a command, and extract the IP addresses it should return, then write them to a file. It is my understanding that I can do this with read
.
grep -v '^#' /opt/pp1/projectprefixed/peeringinfo > /opt/pp1/projectprefixed/$DATE/peeringinfo.conf
ip_regex='([0-9]{1,3}\.){3}[0-9]{1,3}'
while IFS=, read NREN router1 peering
do
if [ ! -f /opt/pp1/projectprefixed/$DATE/recFromNRENList/$router1 ]
then
ssh -q -n -o StrictHostKeyChecking=no srv_oc_scripts@$router1 "show route recieve-protocol bgp" | grep -o "$ip_regex" > peeringsReceived
fi
done < $router1
The table is a text like that looks like this:
NAME1,mx1.ROUTER1,192.168.1.1
NAME2,mx1.ROUTER2,192.168.65.7
However, it returns an "ambiguous redirect" error.