Linux ping一段IP地址范围的一个简单的shell
2012-05-08 17:45
651 查看
找到了一个linux下ping 一IP地址段内网络连通性的脚本。
假如脚本名称为pingip.sh 使用方式为:
#./pingip.sh 1 255
表示ping 192.168.0.1----255段内的设备。
#!/bin/bash
#
# Purpose: This program uses for detect a range of IP online or not
# print OK if online, otherwise print Failed
#
# Written by Dooit, dooit.lee@gmail.com
# Tue Feb 22, 2011
#
if [ $# -lt 2 -o $1 -gt $2 ]; then
echo "Usage: `basename $0` <begin> <end>"
exit 1
fi
echo "This program uses for detecting a range of IPs online or not"
echo "NOTE: This program only ping for 192.168.0.0 network"
network="192.168.0."
# ping each ip in sequence between $1 and $2
for ip in $(seq $1 $2)
do
# sed and awk ping situation if you want
if ping -c 1 ${network}${ip} >& /dev/null
then
echo "${network}${ip}: OK"
else
echo "${network}${ip}: Failed"
fi
[b][b][b]done[/b][/b][/b]
假如脚本名称为pingip.sh 使用方式为:
#./pingip.sh 1 255
表示ping 192.168.0.1----255段内的设备。
#!/bin/bash
#
# Purpose: This program uses for detect a range of IP online or not
# print OK if online, otherwise print Failed
#
# Written by Dooit, dooit.lee@gmail.com
# Tue Feb 22, 2011
#
if [ $# -lt 2 -o $1 -gt $2 ]; then
echo "Usage: `basename $0` <begin> <end>"
exit 1
fi
echo "This program uses for detecting a range of IPs online or not"
echo "NOTE: This program only ping for 192.168.0.0 network"
network="192.168.0."
# ping each ip in sequence between $1 and $2
for ip in $(seq $1 $2)
do
# sed and awk ping situation if you want
if ping -c 1 ${network}${ip} >& /dev/null
then
echo "${network}${ip}: OK"
else
echo "${network}${ip}: Failed"
fi
[b][b][b]done[/b][/b][/b]
相关文章推荐
- 一个简单的防CC攻击Shell脚本分享
- 一个简单统计时间间隔的shell脚本Demo
- C语言 实现一个简单的Shell (支持管道和"cd")
- 一个简单的防CC攻击Shell脚本分享
- 【小项目】:使用shell编写一个简单的告警系统
- 简单算法--一个整形数逆序输出后正序输出/一段精彩的递归代码
- 一个简单的shell脚本-----实现虚拟机实验环境的简单配置
- 用shell脚本写的一个简单的计算器
- 自己动手写一个简单的Shell之四:流程控制
- shell遍历一个日期范围
- 一个备份MySQL数据库的简单Shell脚本
- csapp实验,一个简单的shell. Lab Assignment L5: Writing Your Own Unix Shell
- 一个简单地Shell-like 的实现
- 实现一个简单的shell
- 用C语言编写一个Linux下的简单shell程序
- 怎样用shell脚本写一个简单的计算器
- 如何DIY一个简单的反弹Shell脚本
- 一个简单的MySQL备份Shell脚本
- 一个简单的自动创建Shell脚本的脚本
- linux中新增一个shell命令最简单的方法