2017年最新企业面试题之shell(二)
#!/bin/bash[ -f /etc/init.d/functions ] && . /etc/init.d/functions||exit1
# 验证系统函数文件是否存在,如存在则调用系统函数,否则退出!
ips="192.169.5."
for i in $(seq 254)
do
ping -c 2 $ips$i >/dev/null 2>/dev/null
if [ "$?" == "0" ]
then
echo "echo $ips$i is online" >>/root/ip_online.txt
else
echo "echo $ips$i is not online" >>/root/ip_noline.txt
fi
done
if [ "$ips$i" != "192.169.5.255" ];then
action "shell脚本执行完毕!" /bin/true
fi
页:
[1]