centos7编写shell批处理文件和执行方法

centos7编写shell批处理文件和执行方法

cd /;

vi shownet.sh;

//shownet.sh批处理内容如下:

#!/bin/bash
ping -c 4 www.qq.com;
ping -c 4 192.168.10.99;
ping -c 4 192.168.20.11;
ping -c 4 192.168.10.24;
echo 'good';

执行shell批处理文件方法:

./shownet.sh

报如下错误处理方法:
cenos7.0 bash :permission denied

chmod 700 shownet.sh

然后再执行批处理

./shownet.sh

[root@test /]# ./shownet.sh
PING www.qq.com (182.140.167.44) 56(84) bytes of data.
64 bytes from 182.140.167.44 (182.140.167.44): icmp_seq=1 ttl=128 time=7.27 ms
64 bytes from 182.140.167.44 (182.140.167.44): icmp_seq=2 ttl=128 time=4.38 ms
64 bytes from 182.140.167.44 (182.140.167.44): icmp_seq=3 ttl=128 time=5.95 ms
64 bytes from 182.140.167.44 (182.140.167.44): icmp_seq=4 ttl=128 time=5.89 ms

--- www.qq.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 4017ms
rtt min/avg/max/mdev = 4.383/5.877/7.274/1.027 ms
PING 192.168.10.99 (192.168.10.99) 56(84) bytes of data.
64 bytes from 192.168.10.99: icmp_seq=1 ttl=128 time=1.44 ms
64 bytes from 192.168.10.99: icmp_seq=2 ttl=128 time=2.49 ms
64 bytes from 192.168.10.99: icmp_seq=3 ttl=128 time=1.22 ms
64 bytes from 192.168.10.99: icmp_seq=4 ttl=128 time=2.19 ms

--- 192.168.10.99 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 1.229/1.840/2.493/0.521 ms
PING 192.168.20.11 (192.168.20.11) 56(84) bytes of data.
64 bytes from 192.168.20.11: icmp_seq=1 ttl=128 time=2.61 ms
64 bytes from 192.168.20.11: icmp_seq=2 ttl=128 time=2.02 ms
64 bytes from 192.168.20.11: icmp_seq=3 ttl=128 time=1.76 ms
64 bytes from 192.168.20.11: icmp_seq=4 ttl=128 time=1.97 ms

--- 192.168.20.11 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 1.762/2.092/2.611/0.318 ms
PING 192.168.10.24 (192.168.10.24) 56(84) bytes of data.
64 bytes from 192.168.10.24: icmp_seq=1 ttl=128 time=1.62 ms
64 bytes from 192.168.10.24: icmp_seq=2 ttl=128 time=1.10 ms
64 bytes from 192.168.10.24: icmp_seq=3 ttl=128 time=1.02 ms
64 bytes from 192.168.10.24: icmp_seq=4 ttl=128 time=1.01 ms

--- 192.168.10.24 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3006ms
rtt min/avg/max/mdev = 1.010/1.191/1.626/0.256 ms
good
相关文章
相关标签/搜索