-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwhole-pinging.sh
40 lines (39 loc) · 1.3 KB
/
whole-pinging.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/bin/bash
if [ "$1" == "" ];
then
echo "type whole-pinging.sh -h for more."
elif [ "$1" == "-h" ];
then
echo -e "Usage: \n to ping a network ips: whole-pinging.sh *Network ip* \n for help: whole-pinging.sh -h\n to set a range: use -r \n"
echo -e "Exmaples: \n whole-pinging.sh 192.168.1.* \"put the star, where the number you want to change\"\n So the script goes to ping from 192.168.1.0 to 192.168.1.254\n\n to set a range: whole-pinging.sh 192.168.1.* -r 1 10 \n So it goes to ping from 192.168.1.1 to 192.168.1.10 \n by default 0 to 254 \n\n"
echo " /**********************************/
/* Simple tool */
/* By OxAbdulrahman */
/* Thank You for Using My tool (: */
/**********************************/"
elif [ "$2" == "-r" ];
then
start=$3
end=$4
for x in $(seq "$start" "$end");do
y=$(echo $1 | sed "s/*/$x/g")
result=$(ping -c 1 $y | grep -oP '1 received')
if [ "$result" == "1 received" ];
then
echo "$y is up"
else
echo "$y is down"
fi
done
else
for x in $(seq 0 254);do
y=$(echo $1 | sed "s/*/$x/g")
result=$(ping -c 1 $y | grep -oP '1 received')
if [ "$result" == "1 received" ];
then
echo "$y is up"
else
echo "$y is down"
fi
done
fi