Created
August 2, 2019 06:53
-
-
Save jptalusan/e9cabc1c7dc7675c5690492634bc62bc to your computer and use it in GitHub Desktop.
For pinging things connected to the ethernet at port eno1 of the device you are using.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
declare -A devices | |
devices["name"]="MAC_address" | |
for i in "${!devices[@]}" | |
do | |
#echo "key: $i" | |
#echo "value: ${devices[$i]}" | |
arp=$(sudo arp-scan --interface=eno1 --local | grep ${devices[$i]}) | |
arp_arr=( $arp ) | |
if [ "$i" = "nuc1" ]; then | |
ip=$(/sbin/ifconfig eno1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') | |
echo "${ip} $i" | |
else | |
echo "${arp_arr[0]} $i" | |
fi | |
done | |
for i in "${!devices[@]}" | |
do | |
arp=$(sudo arp-scan --interface=eno1 --local | grep ${devices[$i]}) | |
arp_arr=( $arp ) | |
#echo "$i ${devices[$i]} ${arp_arr[0]}" | |
if [ "$i" = "nuc1" ]; then | |
ip=$(/sbin/ifconfig eno1 | grep 'inet addr:' | cut -d: -f2 | awk '{ print $1}') | |
echo "$i ${devices[$i]} ${ip}" | |
else | |
echo "$i ${devices[$i]} ${arp_arr[0]}" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment