标签:lse $1 echo 使用 ++ pre status for info
今天需要新开一个vlan,准备给用192.168.12.0/24网络,测试下这个段ip有没有被使用,批量ping下这个网段[root@xiaoxuan ~]# cat ping.sh
#!/bin/bash
if [ -z "$1" ];then
echo -e "\033[40;33mUsage: /bin/bash ping.sh 192.168.16\033[40;37m"
exit 1
fi
for ((i=1;i<=254;i++));do
ping -c 1 $1.$i > /dev/null 2>&1
if [ $? -eq 0 ];then
echo -e "\033[40;32mThe server "$1"."$i" status is UP\n\033[40;37m"
else
echo -e "\033[40;31mThe server "$1"."$i" status is DOWN\n\033[40;37m"
fi
done
[root@xiaoxuan ~]# ./ping.sh
Usage: /bin/bash ping.sh 192.168.16
[root@xiaoxuan ~]# ./ping.sh 192.168.13
The server 192.168.13.1 status is UP
The server 192.168.13.2 status is DOWN
标签:lse $1 echo 使用 ++ pre status for info
原文地址:https://blog.51cto.com/7585527/2417372