#!/bin/sh # Send a wake-on-lan packet to a machine, ping it until it responds, and # then execute the specified command (e.g. ssh, vncviewer etc). # By Philip Endecott, 2008. # I hereby place this code in the public domain. set -e case $# in 0|1) echo "Usage: wakethen " exit 1 ;; *) esac hostname=$1; shift; wakeonlan $hostname while true do if ping -c 1 -w 10 $hostname then break fi done exec "$@"