Is it possible to implement the wake-on-lan magic packet in bash? I'm using a old, customized BusyBox and don't have ether-wake. Is it possible to replace it with some other shell command, like:wakeonlan 11:22:33:44:55:66
Wake-on-LAN with BusyBox?
busybox;wake on lan
You need something that's capable of sending an Ethernet packet that will be seen by the device you want to wake up.The ether-wake command in BusyBox is exactly what you're after. If your BusyBox doesn't have it, consider recompiling BusyBox to include it.If you have a sufficiently bloaty netcat (BusyBox can have one of two nc implementations, one of which handles TCP only), you can send a manually crafted UDP packet to the broadcast address of the network segment that the device is connected to.mac=$(printf '\xed\xcb\xa9\x87\x65\x43') # MAC = ed:cb:a9:87:65:43wol_packet=$(printf \xff\xff\xff\xff\xff\xff$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac$mac)echo $wol_packet | nc -u 7 192.0.2.255Another BusyBox utility that you could abuse into sending that packet is syslogd.syslogd -n -O /dev/null -l 0 -R 192.0.2.255/7 &syslogd_pid=$!logger $wol_packetkill $!If the MAC contains a null byte, you won't be able to craft the packet so easily. Pick a byte that's not \xff and that's not in the MAC, say \x42 (B), and pipe through tr.echo $wol_packet | tr B '\000' | nc -u 7 192.0.2.255If you really have bash (which is extremely unusual on devices with BusyBox  are you sure you really have bash, and not another shell provided by BusyBox?), it can send UDP packets by redirecting to /dev/udp/$hostname/$port.echo $wol_packet >/dev/udp/192.0.2.255/7