#! /bin/sh
## confirm params
if [ `echo $* | awk '{print NF}'` -eq 0 ];then
echo "please select a file!"
exit 0
fi
## confirm file path
file=$1
if [ `expr match $file '/'` -eq 0 ];then
file=`pwd`/$file
fi
if [ -e $file -a -f $file ];then
echo "begin~"
else
echo "not exists : $file"
exit 0
fi
## do ping
for line in `cat $file`
do
res=`ping -c 1 $line | grep loss|awk '{print $6}'|awk -F "%" '{print $1}'`
if [ $res -eq 100 ];then
echo ping \"$line\" \t\t fail
else
echo ping \"$line\" \t\t ok
fi
done