Skip to content

Instantly share code, notes, and snippets.

@hfs
Created November 28, 2013 08:22
Show Gist options
  • Save hfs/7688764 to your computer and use it in GitHub Desktop.
Save hfs/7688764 to your computer and use it in GitHub Desktop.
Wake on LAN, then ping until the host is up
#!/bin/sh
HOST=hostname
MAC=12:34:56:78:90:AB
wakeonlan $MAC
# Wait until the host is pingable
count=0
while [ $count -lt 300 ]; do
let count++
if ping -q -c 1 $HOST > /dev/null; then
echo
exit 0
fi
echo -n .
if [ $(( $count % 80 )) -eq 0 ]; then
echo
fi
done
echo
echo "Host '$HOST' does not seem to have come up? Giving up."
exit 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment