Posts tagged Shell script to check if remote host is up

Simple shell script to check if a Host is UP

If you work on multiple servers and want to check what hosts are up/down then you can use the below shell script to  test multiple servers  connectivity ::

# test1.txt should contain a list of IP's to be tested
for i in `cat test1.txt`;
ping -c 1 -W 1 $i &> /dev/null
if [ $? -ne 0 ]; then
#use if [ $? -eq 0 ]; then to test the up IP's
echo "$i is down"

That’s all.