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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值