#!/bin/bash

#used for cli command "show ipv6-neighbors"
#no input and output var


echo|awk '{print "Address                                    HW Address           Interface"}'
echo|awk '{print "---------------------------------------    -----------------    ---------"}'

filename="/tmp/arp.txt"
mapfile="/tmp/run/vlan_interfaces"
/sbin/ip -6 neigh | sed '/FAILED/d' | awk '{printf("%-43s%-21s%-9s\n", $1, $5, $3)}'>$filename
awk -v myreal=eth0 '{for(i=NF;i<=NF;i++) if($i ~/'eth0'$/){printf("%-43s%-21s%-9s\n",$1,$2,myreal)}}' $filename
awk -v myreal=eth1 '{for(i=NF;i<=NF;i++) if($i ~/'eth1'$/){printf("%-43s%-21s%-9s\n",$1,$2,myreal)}}' $filename
if [ -f $mapfile ]
then
    while read line
    do
        printname=`echo $line | awk '{print $1}'`
        realname=`echo $line | awk '{print $2}'`
        awk -v myreal=$printname '{for(i=NF;i<=NF;i++) if($i ~/'$realname'$/){printf("%-43s%-21s%-9s\n",$1,$2,myreal)}}' $filename
    done < $mapfile
fi

exit 0

