bornpilot wrote:
As for your second suggestion I would gather I would add the script to each host system?
No. Only to the .bash_login of the user account on the computer that you will be issuing the ping to the entire subnet, to get the IP address, MAC address, and hostname of every other computer on the subnet (you'll get the IP address of your computer, too, but it won't give MAC address and hostname because your own computer isn't in your computer's arp tables)
What this command does when it does the ping, it is pinging the IP address of the result of the stuff inside the backticks. That stuff is the result of an ifconfig command of the computer that you are on, filtering just the broadcast IP address out of all the junk returned by ifconfig. The 6th field of the broadcast line of ifconfig is the broadcast address. So you're pinging the broadcast address and everybody on the subnet responds. The icmp "grep" filter rejects lines that for whatever reason don't have icmp in them (can't give any examples but ran across some when I was building this way back when). The awk '{print $\4}' extracts the IP address of every ping response of every computer on the subnet. They are extracted with an appended colon, which the cut removes. Then they are sorted numerically by IP address, uniq removes any duplicate responses from the multiple pings, and then the list of responding IP addresses is passed to arp, which gives back the MAC address and hostname of each responding IP address on your subnet. I've also executed this command on my work computer, whose subnet is 255.255.254.0 and almost every IPA is in use there. So I know it works. Just remember, if done from the keyboard, it's awk '{print $4}' and in the .bash_login, when you are defining the alias command, it's awk '{print \$4}'. Don't know why, just that if you don't it doesn't work. You could probably build your alias to cat the results to a file, or put it as a standalone script file launched by launchd or cron.