Bash測試網絡是否連通
[plain]
#!/bin/bash
#使用Google的公共DNS測試
echo
echo "test network connection ... 測試網絡連接 ..."
echo
PINGRET=$( ping 8.8.8.8 -c 4 | grep "icmp_" )
#echo $PINGRET
[ -z "$PINGRET" ] &&
{
PINGRET=$( ping 8.8.4.4 -c 4 | grep "icmp_" )
[ -z "$PINGRET" ] &&
{
echo "no network connection ... 無網絡連接... 請再連接或是修改參數後再測試..."
exit 1;
}
}||
{
echo "test network successfully ... 網絡連接暢通 ... 可進行軟件安裝"
exit 0;
}