#!/bin/sh host=probook host_mac=2c:41:38:08:6c:44 timeout=1 # when no count parameter is set use 1 if [ $# -ne 0 ]; then timeout=$1 fi echo -n "Checking if $host is already alive... " ping -c 1 $host >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "yes. Done" exit 0 fi echo "no." echo -n "Trying to wake up $host ... " while [ $timeout -gt 0 ]; do wol $host_mac >/dev/null 2>&1 ping -c 1 $host >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "success." exit 0 fi ((timeout--)) echo "no." echo -n "Re-trying to wake up $host ... " done echo "no." echo "Unable to wake up $host" exit 1