Skip to content

Instantly share code, notes, and snippets.

@tashrifbillah
Created November 2, 2022 18:20
Show Gist options
  • Save tashrifbillah/436805f1534d170eeb9f20541bc7a495 to your computer and use it in GitHub Desktop.
Save tashrifbillah/436805f1534d170eeb9f20541bc7a495 to your computer and use it in GitHub Desktop.
Obtain MAC addresses in CSV format
#!/bin/bash
# master script
for p in $(cat ip_addr.txt)
do
echo -n 172.21.$p,; ssh [email protected].$p -i ~/.ssh/id_ecdsa -o StrictHostKeyChecking=no -C "~/get_mac_addr.sh"; done
# slave script
str1=`ip addr | grep BROADCAST,MULTICAST,UP,LOWER_UP`
IFS=': ' read -ra names <<< $str1
echo `hostname -f`,`cat /sys/class/net/${names[1]}/address`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment