#!/bin/bash
#
# This script tries to tune a specified DVB channel 100 times with szap 
# and counts the failed and successful locks.
#
# Manu Abrahams hacked szap (http://abraham.manu.googlepages.com/szap.c)
# has a bug and does not return the correct exit code when when started with the -x parameter.
#
# You proberly need this patch http://www.makhutov.org/downloads/dvb/szap.patch
# to fix the problem and make this script work.
#

FAILES=0
TUNES=0
for i in `seq 1 100`
do
	#date +%F--%H-%M-%S
	szap -x -t 0 'ProSieben'
	if [ "$?" = "0" ]
	then
		let TUNES+=1
	else
		let FAILES+=1
	fi
	
	echo "Try: $i"
	echo "Failes: $FAILES"
	echo "Tunes: $TUNES"
	#sleep 15
done

echo "Finished:"
echo "Failes: $FAILES"
echo "Tunes: $TUNES"
