Remotely Power on and Ping a system Andrew Mallett | Updated September 2013

This is a development of the Remote Power On script which uses Wake-on-LAN to power up a Unix/Linux system across a network, from a workstation or mobile phone.

This script will keep pinging the activated system and will show an alert when it comes on-line..

echo Waking Goth Server..

wakeonlan -p 7 00:64:09:1a:fe:9b

gothstate=`ping goth -c1 | grep icmp | cut -c 1-2`

echo Checking Goth Server status..

 while [ $gothstate = "Fr" ]
 echo -n ". "
 gothstate=`ping goth -c1 | grep icmp | cut -c 1-2`

echo Goth is on-line.

Following the initial wakeonlan command, the script then creates a variable, gothstate. This variable is created by pinging the host once and then grepping and cutting out the first two characters of the icmp reply.

If the remote system is not yet reachable, we know that the reply will begin "From hostname (IP Address) icmp_seq= " etc.. So we can grep and cut for the first two characters Fr ..

However when the remote system comes on-line we know the reply will start with "64 bytes from hostname (IP Address) icmp_seq= " etc. and we grep and cut for these two characters..

The script loop dictates that while the remote system remains unreachable, echo a series of sequential dots, one per ping. Once the gothstate variable becomes 64 the loop exits and echoes a message that the remote server is on-line.

If the script keeps pinging past the remote server's usual boot-up duration, it's time to investigate further..



Comments (0)

E-mail (Will not appear online)
;-) :-) :-D :-( :-o :-O B-) :oops: :-[] :-P
To prevent automated Bots form spamming, please enter the text you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
This comment form is powered by GentleSource Comment Script. It can be included in PHP or HTML files and allows visitors to leave comments on the website.

PHP Scripts   Disposable Email   Throwaway Email