IBM Support

testping - repeatedly ping while waiting for a system to reboot

How To


Summary

If you are waiting for a host to reboot, sometimes, it can take quite a while. For example if you are updating an HMC, the reboot includes updating a large part of the operating system.
You may want to get on with some other work while you wait. This script will let you know when the host is back.

Objective

Banner_AIX_i_Linux

Environment

You will need an AIX or other Unix/Linux platform to run the script.
Here is the script:
################################################################
#                                                              #
# A simple script to ping a host and then repeat after a delay #
#                                                              #
#   Written by Gareth Coates gaz@uk.ibm.com in November 2019   #
#                                                              #
#                Copyright (c) IBM 2019                        #
#                                                              #
################################################################

# $1 is the hostname or IP address to ping
# $2 is the required tiome delay - it defaults to 10 seconds

wait=$2
wait=${wait:=10}
echo wait = $wait

# Check the OS and set the particular command to echo cotrol characters
[ $(uname -s) = Linux ] && ECHO="echo -e"
[ $(uname -s) = AIX ]   && ECHO=echo

while :
do
ping -c 1 -w 1 -q $1 >/dev/null 2>&1 && $ECHO \\007 Hit CTRL-C to exit ...
sleep $wait
done
$1 = The first positional parameter is required - it is the hostname or IP address to ping.
$2 = The second positional parameter is optional and is the delay in secopnds between each ping. It defaults to 10 seconds.
The ping command has the following options
-c 1 count of 1 packet
-w 1 timeout of 1 second
-q quiet

Steps

So you simply run the script, specifying the hostname or IP address and an optional delay.
When the host is back up and responding to a ping, the script sounds a BEL and you can interrupt with CTRL-C

Additional Information

You can contact me: 

Document Location

Worldwide

[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"HW1A1","label":"IBM Power Systems"},"Component":"","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF041","label":"HMC"},{"code":"PF016","label":"Linux"}],"Version":"All Versions","Edition":"","Line of Business":{"code":"LOB57","label":"Power"}}]

Document Information

Modified date:
03 May 2021

UID

ibm11115907