jpoliv / wakeonlan

Perl script for waking up computers via Wake-On-LAN magic packets
306 stars 32 forks source link

permit hostname for mac addr argument, resolved via /etc/ethers #12

Open jmtd opened 1 year ago

jmtd commented 1 year ago

It would be nice if we could specify a hostname in place of the MAC address argument, and for wakeonlan to attempt to look this up via nss/nsswitch/the ethers db (e.g. /etc/ethers).

Note that this would be to resolve a hostname to a MAC address, not to specify an IP for the WOL packet.

Examples

$ getent ethers coil
e0:4f:43:e6:2b:36 coil
$ wakeonlan $(getent ethers coil | awk '{ print $1 }')
Sending magic packet to 255.255.255.255:9 with e0:4f:43:e6:2b:36

getent(1) implies that the libc function to do this correctly is ether_hostton.