Created
November 28, 2013 08:22
-
-
Save hfs/7688764 to your computer and use it in GitHub Desktop.
Wake on LAN, then ping until the host is up
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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