Categories
FreeBSD/Unix

Wake up on LAN

Simple script for sending wake-up on LAN packets (using wol from ports) first three in a row and then every 60 seconds. The port number should be whatever the device is listening (9 is the port that Buffalo Linkstation is listening).

#!/bin/sh
#
# Author: Jan Melen-jan(at)melen.org
#
R=1; 
QUITFILE="/tmp/quit_wol.$$"
WOL="/usr/local/bin/wol"
WOLADDR="192.168.24.2 00:24:a5:00:a6:04"
WOLPORT="9"
echo "To quit press CTRL-C or touch ${QUITFILE}"

$WOL -p ${WOLPORT} -i ${WOLADDR} > /dev/null; sleep 1
$WOL -p ${WOLPORT} -i ${WOLADDR} > /dev/null; sleep 1
while [ $R -eq 1 ]; do
    $WOL -p ${WOLPORT} -i ${WOLADDR} > /dev/null
    if [ -f ${QUITFILE} ]; then
        rm ${QUITFILE}
        exit 0
    fi
    sleep 60
done