Commit dd1f54be authored by joubran's avatar joubran

the third question

parent 0a49b106
#!/bin/bash
touch file
echo "$1" > file
first=$(echo $($file | cut -d"-" -f 1 | cut -d"." -f 4))
second=$(echo $($file | cut -d"-" -f 2 | cut -d"." -f 4))
if [ $first -lt $second ];
then
for n in {$first..$second}; do
host=192.168.1.$n
ping -c2 $host &> /dev/null
if [ $? = 0 ]; then
echo "$host is UP"
else
echo "$host is DOWN"
fi
done
fi
#!/bin/bash
touch file
echo "$1" > file
first=$(echo $($file | cut -d"-" -f 1 ))
second=$(echo $($file | cut -d"-" -f 2 ))
x=$(echo $(cut -d"." -f 4 $first))
y=$(echo $(cut -d"." -f 4 $second))
if [ $x -lt $y ];
then
for n in {$x..$y}; do
host=192.168.1.$n
ping -c2 $host &> /dev/null
if [ $? = 0 ]; then
echo "$host is UP"
else
echo "$host is DOWN"
fi
done
fi
192.168.1.7-192.168.1.123
192.168.1.7-192.168.1.123
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