我有一个Shell脚本,可以ping一个域并回显失败或确定 问题在于,即使我在shellscript中将其更改,debian也会以某种方式缓存ping请求并始终ping相同的域。
#!/bin/sh
# -q quiet
# -c nb of pings to perform
ping -c5 google.com
if [ $? -eq 0 ]
then
echo "ok"
else
echo "failed"
fi
编辑:
当前输出:
PING germandeathsystem.de (193.25.100.197) 56(84) bytes of data.
64 bytes from germandeathsystem.de (193.25.100.197): icmp_seq=1 ttl=64 time=0.100 ms
64 bytes from germandeathsystem.de (193.25.100.197): icmp_seq=2 ttl=64 time=0.063 ms
64 bytes from germandeathsystem.de (193.25.100.197): icmp_seq=3 ttl=64 time=0.052 ms
64 bytes from germandeathsystem.de (193.25.100.197): icmp_seq=4 ttl=64 time=0.101 ms
64 bytes from germandeathsystem.de (193.25.100.197): icmp_seq=5 ttl=64 time=0.060 ms
预期输出:
PING google.com (172.217.16.78) 56(84) bytes of data.
64 bytes from ham11s01-in-f14.1e100.net (172.217.16.78): icmp_seq=1 ttl=55 time=5.45 ms
64 bytes from ham11s01-in-f14.1e100.net (172.217.16.78): icmp_seq=2 ttl=55 time=5.59 ms
64 bytes from ham11s01-in-f14.1e100.net (172.217.16.78): icmp_seq=3 ttl=55 time=5.49 ms
64 bytes from ham11s01-in-f14.1e100.net (172.217.16.78): icmp_seq=4 ttl=55 time=5.50 ms
64 bytes from ham11s01-in-f14.1e100.net (172.217.16.78): icmp_seq=5 ttl=55 time=5.46 ms
为什么仍对germandeathsystem.de而不是google.com进行ping操作?