Wake-on-LAN Wrapper Script Revisited
Almost a year ago, I posted this article describing a simple, CLI-based way to trigger the Wake-on-LAN magic packet on your network to wake a sleeping machine. Trouble is, that script is showing its age, taking advantage of some deprecated utilities to perform its function. This updated script performs the same task using a more modern toolchain.
#!/bin/sh
# find the IP address in the output of `nslookup`
ip=`nslookup imac | tail -2 | head -1 | awk '{print $2}'`
# find the MAC address in the output of `ip neigh`
mac=`ip neigh | grep -i -m1 $ip | awk '{print $5}'`
# send the magic packet
wol -h $ip $mac
The ip utility replaces ifconfig, arp, and many other utilities in most current Linux distributions.
Read other posts