我写了个脚本测试网络是否正常,如果接受的received的包为0就提示 但为什么一运行该脚本就总是提示:
ping: unknown host 192.168.1.1|awk
network is ok
以下是我的脚本内容
#!/bin/sh
ping="ping -c 3 191.168.1.1|awk NR==7'{print $4}'"
if $ping = 0
then
echo "nework is timeout"
else
echo "network is ok"
tophy11754 于 2008-11-06 22:50:43发表:
错了。试试下面的
#!/bin/bash
ping=`ping -c 3 191.168.1.1|awk 'NR==7 {print $4}'`
if [ $ping -eq 0]
then
echo "network is timeout"
else
echo "network is ok"
fi
tophy11754 于 2008-11-06 22:40:38发表:
试了下,好像脚本写错了啊。
#!/bin/bash
ping=`ping -c 3 191.168.1.1|awk 'NR==7 {print $4}'`
if $ping==0
then
echo "network is timeout"
else
echo "network is ok"
fi