3004.脚本作业―l201.2.0编写一个脚本用于检测IP地址(递进版2)
2012-04-27 00:58
281 查看
l201.2.0: 在linux01a中编写一个脚本,用于检测IP地址是否能够PING通
(一次发3个包,其中任一个能够ping通,则认为此IP能够ping通)
脚本命名:l201.2.0.ping.sh 小版本改进编号: l201.2.x.ping.sh x从0,1,2,3递增
环境说明:
linux01a中有IP地址 192.168.0.1,192.168.0.31,192.168.0.41
linux01b中有IP地址 192.168.0.2,192.168.0.51,192.168.0.61
在实验前,应先检查以上地址均能够ping通.
在命令行下执行ping命令,如果IP地址能够ping通(只要有一个包能PING通即可),则如下显示
[root@linux01 ~]# ping -c 3 192.168.0.31
PING 192.168.0.31 (192.168.0.31) 56(84) bytes of data.
64 bytes from 192.168.0.31: icmp_seq=1 ttl=128 time=0.177 ms
64 bytes from 192.168.0.31: icmp_seq=2 ttl=128 time=0.317 ms
64 bytes from 192.168.0.31: icmp_seq=3 ttl=128 time=0.133 ms
--- 192.168.0.31 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.133/0.209/0.317/0.078 ms
在命令行下执行ping命令,如果IP地址不能够ping通(3个包均不通),则如下显示
[root@linux01 ~]# ping -c 3 192.168.0.100
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
From 192.168.0.11 icmp_seq=1 Destination Host Unreachable
From 192.168.0.11 icmp_seq=2 Destination Host Unreachable
From 192.168.0.11 icmp_seq=3 Destination Host Unreachable
--- 192.168.0.100 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2001ms
, pipe 3
脚本要求:
编写一个shell脚本,执行脚本后自动ping以下地址:192.168.0.1,192.168.0.31,192.168.0.2,192.168,0.91
以上IP地址直接写在脚本之中。执行完成后,应显示能够ping通的IP地址和不能够ping通的IP地址。
根据环境的IP配置,能ping通的IP地址有192.168.0.1,192.168.0.31,192.168.0.2
不能ping通的IP地址有192.168.0.91
注:ping命令发3个包,只要其中一个包能ping通,则可认为此IP能够ping通
附件是脚本实验环境拓扑图.
shell脚本系列视频访问链接:
(一)shell脚本与应用示例
(二)三剑客—文本处理
(三)千机变—脚本变量
(四)向左向右—条件选择
(五)望山跑死马—循环
(六)脚本函数与任务调度
本文出自 “培训师李明峻” 博客,请务必保留此出处http://sop2008.blog.51cto.com/71724/845397
(一次发3个包,其中任一个能够ping通,则认为此IP能够ping通)
脚本命名:l201.2.0.ping.sh 小版本改进编号: l201.2.x.ping.sh x从0,1,2,3递增
环境说明:
linux01a中有IP地址 192.168.0.1,192.168.0.31,192.168.0.41
linux01b中有IP地址 192.168.0.2,192.168.0.51,192.168.0.61
在实验前,应先检查以上地址均能够ping通.
在命令行下执行ping命令,如果IP地址能够ping通(只要有一个包能PING通即可),则如下显示
[root@linux01 ~]# ping -c 3 192.168.0.31
PING 192.168.0.31 (192.168.0.31) 56(84) bytes of data.
64 bytes from 192.168.0.31: icmp_seq=1 ttl=128 time=0.177 ms
64 bytes from 192.168.0.31: icmp_seq=2 ttl=128 time=0.317 ms
64 bytes from 192.168.0.31: icmp_seq=3 ttl=128 time=0.133 ms
--- 192.168.0.31 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.133/0.209/0.317/0.078 ms
在命令行下执行ping命令,如果IP地址不能够ping通(3个包均不通),则如下显示
[root@linux01 ~]# ping -c 3 192.168.0.100
PING 192.168.0.100 (192.168.0.100) 56(84) bytes of data.
From 192.168.0.11 icmp_seq=1 Destination Host Unreachable
From 192.168.0.11 icmp_seq=2 Destination Host Unreachable
From 192.168.0.11 icmp_seq=3 Destination Host Unreachable
--- 192.168.0.100 ping statistics ---
3 packets transmitted, 0 received, +3 errors, 100% packet loss, time 2001ms
, pipe 3
脚本要求:
编写一个shell脚本,执行脚本后自动ping以下地址:192.168.0.1,192.168.0.31,192.168.0.2,192.168,0.91
以上IP地址直接写在脚本之中。执行完成后,应显示能够ping通的IP地址和不能够ping通的IP地址。
根据环境的IP配置,能ping通的IP地址有192.168.0.1,192.168.0.31,192.168.0.2
不能ping通的IP地址有192.168.0.91
注:ping命令发3个包,只要其中一个包能ping通,则可认为此IP能够ping通
附件是脚本实验环境拓扑图.
shell脚本系列视频访问链接:
(一)shell脚本与应用示例
(二)三剑客—文本处理
(三)千机变—脚本变量
(四)向左向右—条件选择
(五)望山跑死马—循环
(六)脚本函数与任务调度
本文出自 “培训师李明峻” 博客,请务必保留此出处http://sop2008.blog.51cto.com/71724/845397
相关文章推荐
- 3007.脚本作业―l201.5.0编写一个脚本用于检测IP地址(递进版5)
- 3008.脚本作业―l201.6.0编写一个脚本用于检测IP地址(递进版6)
- 3009.脚本作业―l201.7.0编写一个脚本用于检测IP地址(递进版7)
- 3010.脚本作业―l201.8.0编写一个脚本用于检测IP地址(递进版8)
- 3012.脚本作业―l201.10.0编写一个脚本用于检测IP地址(递进版10)
- 3005.脚本作业―l201.3.0编写一个脚本用于检测IP地址(递进版3)
- 3006.脚本作业―l201.4.0编写一个脚本用于检测IP地址(递进版4)
- 3011.脚本作业―l201.9.0编写一个脚本用于检测IP地址(递进版9)
- 3003.脚本作业―l201.1.0编写一个脚本用于检测IP地址
- 使用shell编写一个检测系统参数的脚本
- php中用于检测一个地理IP地址是否可用的代码
- SHELL脚本--用于检测一个或者多个对象是文件或者目录
- 一个用于两地进行同步和备份的批处理Bat脚本
- 轻松接触一个检测MySQL状态的脚本
- 随手写的一个检测php连接mysql的小脚本
- 编写一个函数用于将一个整数前后倒置,并调用此函数将一个从键盘输入的 整数前后倒置?
- 如何编写一个shell脚本
- 一个可以自动更改IP地址的脚本
- 作业二:个人编程项目——编写一个能自动生成小学四则运算题目的程序