#!/bin/bash case "$1" in A|a) if [[ -f /tmp/channels ]] #find freqence then rm -rf /tmp/channles fi ## use frequence table for names in us-bcast us-cable us-cable-hrc us-cable-irc japan-bcast japan-cable europe-west europe-east italy newzealand australia ireland france china-bcast southafrica argentina australia-optus do exec ivtv-tune -t$names -l |awk '{print $2}' >> /tmp/channels done ## if thers duplicated freqences sort it out :) sort -u -o /tmp/channels /tmp/channels echo "Please wait" #numbers of freqences numbers=`wc -l /tmp/channels |awk '{print $1}'` for ((i=1; i<="$numbers"; i++)) do Channels[$i]=`cat /tmp/channels | sed -n ""$i"p"` if [[ `ivtv-tune -f${Channels[$i]} | grep -c "De"` = "1" ]] then echo "we got a signal @: ${Channels[$i]} Khz" sleep 1 fi done ;; M|m) if [[ "$2" < "/dev/null" ]] then echo -e "I need a min freq to start with\n Ex: $0 M 50000 800000" exit 1; fi if [[ "$3" < "/dev/null" ]] then echo -e "I need a max freq to stop at Ex: $0 M $2 800000" exit 1; fi MIN_FREQ="$2" MAX_FREQ="$3" #make a freqence step of 250 Khz for (( i="$MIN_FREQ" ; i<= "$MAX_FREQ" ; i+=250)) do # make Khz to Mhz freq=$(bc << EOF scale = 3 ($i/1000) EOF ) ## check if we got a signal detected with ivtv-tune if [[ `ivtv-tune -f $freq | grep -c "De"` = "1" ]] then echo "we got a signal @: ${i} Khz" fi done ;; *) echo "use $0 A or $0 M" ;;