Shell脚本练习——网络相关

测试网络状态

[root@wenzi data]#vim ping.sh 
#!/bin/bash
host=$1
ping $host -c5
if [ $? -eq 0 ];then
	echo "Successful"
else
	echo "Failure"
fi
[root@wenzi data]#bash ping.sh 192.168.29.142
PING 192.168.29.142 (192.168.29.142) 56(84) bytes of data.
64 bytes from 192.168.29.142: icmp_seq=1 ttl=64 time=0.396 ms
64 bytes from 192.168.29.142: icmp_seq=2 ttl=64 time=0.573 ms
64 bytes from 192.168.29.142: icmp_seq=3 ttl=64 time=0.286 ms
64 bytes from 192.168.29.142: icmp_seq=4 ttl=64 time=0.516 ms
64 bytes from 192.168.29.142: icmp_seq=5 ttl=64 time=0.412 ms

--- 192.168.29.142 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 97ms
rtt min/avg/max/mdev = 0.286/0.436/0.573/0.102 ms
Successful

持续更新

你可能感兴趣的:(Linux基础,#,Shell脚本,linux,运维)