Commit 71244984 authored by mouhamad.orabi's avatar mouhamad.orabi

add ex3 to Checks to see if hosts are alive

parent 42512400
#!/bin/bash
# alive2.sh
# Checks to see if hosts are alive
# Iterate through IP addresses
hosts=$1
n1=$(echo $hosts | cut -d "-" -f1 | cut -d "." -f4)
n2=$(echo $hosts | cut -d "-" -f2 | cut -d "." -f4)
for ((n = n1; n <= n2; n++)); do
host=192.168.0.$n
ping -c2 $host &> /dev/null
if [ $? = 0 ]; then
echo "$host is UP"
else
echo "$host is DOWN"
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment