Create a script with expect that will be invoked from a shell script if ping fails:
Code:
#!/usr/bin/expect
spawn telnet mybox
expect {*login:}
send "XXXXXXXX\r"
expect {*password:}
send "XXXXXXXX\r"
expect {*me@mybox# }
send "sudo /sbin/reboot\r"
This code might be slightly wrong. Look at the expect documentation.
WARNING! The username/password combination can be viewed by anyone who reads the script! I use sudo because reboot requires root access, and don't even think about putting the root in a script.