FILE=$1;
PORT=$2;
OUTFILE=$3;

cat $FILE | awk '{print $1}' > uname
cat $FILE | awk '{print $2}' > hname

total=`cat $FILE | wc -l`

echo "" > $OUTFILE

for i in `cat uname`
do
 for j in `cat hname`
 do
   echo "$i $j";
   ../src/checker -u $i -a $j -p $2 >> $OUTFILE 
   echo "...";
 done
done

echo "200 ok"
grep "OnULookup: 200" $OUTFILE | wc -l
temp=`grep \"OnULookup: 200\" $OUTFILE | wc -l`
result=`expr \( $temp \* 100 \) / \( $total \* $total \) `
echo "$result %"
echo ""
echo "200 ok" >> $OUTFILE
echo "$result %" >> $OUTFILE

echo "404 not found"
grep 404 $OUTFILE | wc -l
temp=`grep 404 $OUTFILE | wc -l`
result=`expr \( $temp \* 100 \) / \( $total \* $total \) `
echo "$result %"
echo ""
echo "404 not found" >> $OUTFILE
echo "$result %" >> $OUTFILE

echo "413 time out"
grep 413 $OUTFILE | wc -l
temp=`grep 413 $OUTFILE | wc -l`
result=`expr \( $temp \* 100 \) / \( $total \* $total \) `
echo "$result %"
echo ""
echo "413 time out" >> $OUTFILE
echo "$result %" >> $OUTFILE

echo "Peer count: $total"