我的iMac的Wi-Fi有点不稳定。有时候它显示连接正常且信号满格,但是Safari或Chrome无法加载网页。我必须关闭/打开Wi-Fi才能解决问题。
奇怪的是,在终端上ping google.com时,我没有任何数据包丢失。
PING www.google.com (68.104.213.123):
56 data bytes 64 bytes from 68.104.213.123: icmp_seq=0 ttl=52 time=21.530 ms
--- www.google.com ping statistics ---
1 packets transmitted, 1 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 21.530/21.530/21.530/0.000 ms
我写了这个Apple Script试图解决这个问题,但似乎需要另一种检查实际网络连接的方法,而不仅仅是ping。我该怎么办?
repeat
try
do shell script "ping -o -t 2 www.google.com"
on error
say "Couldn't connect"
do shell script "networksetup -setairportpower en1 off"
do shell script "sleep 5"
do shell script "networksetup -setairportpower en1 on"
end try
delay 60
end repeat
PING www.google.com (68.104.213.123): 56 data bytes
64 字节来自 68.104.213.123:icmp_seq=0 ttl=52 time=21.530 ms
--- www.google.com ping 统计信息 ---
已传输 1 个数据包,收到 1 个数据包,丢失率 0.0%
往返行程的最短时间/平均时间/最长时间/标准差 = 21.530/21.530/21.530/0.000 ms
- guisauer