编写脚本测试192.168.4.0/24整个网段中哪些主机处于开机状态,哪些主机处于关机状态(while版本)-《shell脚本》

admin 2025-11-06 14:23:29 系统网络 来源:ZONE.CI 全球网 0 阅读模式
    1. #!/bin/bash
    2. i=1
    3. while [ $i -le 254 ]
    4. do
    5. ping ‐c2 ‐i0.3 ‐W1 192.168.4.$i &>/dev/null
    6. if [ $? –eq 0 ];then
    7. echo "192.168.4.$i is up"
    8. else
    9. echo "192.168.4.$i is down"
    10. fi
    11. let i++
    12. done
    01-shell脚本介绍-《shell脚本》 系统网络

    01-shell脚本介绍-《shell脚本》

    一、shell脚本是什么二、为什么要学shell,而不是其他计算机语言三、学习这门课程的优势四、学了能干什么五、学习什么内容六、学习的技巧七、成长路径八、学习环
    评论:0   参与:  8