#!/bin/bash INPUT="/full/path/hf2.jpg" # or something like that, according to your grabber WORKPNG1="/tmp/workpng1.png" # temporary file WORKPNG2="/tmp/workpng2.png" # temporary file GRABBER="qrsspig" GCONFIG="config-40m.txt" # the filename of configuration file if multiple grabbers are running # ^ this filename can be checked by e.g. "ps -ef | grep qrsspig" LIMIT="50" # the lowest allowed intensity for continuing the grabber while true ; do # never stop this test if [ -f "$INPUT" ] ; then # if the grab does not exist we will not kill the grabber rm $WORKPNG1 rm $WORKPNG2 # we need to analyze only the spectral part of the picture: convert -crop 500x400+100+150 $INPUT $WORKPNG1 # the dimensions and position of the "data" part # now you can check if the selection was OK in workpng1.png convert -resize 50x40\! $WORKPNG1 $WORKPNG2 # decrease the size and some noise # max blue intensity: MAX=$( convert $WORKPNG2 txt: | awk -F "(" '{print $2}' | awk -F ")" '{print $1}'| awk -F "," '{print $3}' | sort -n | tail -1 ) echo -n "max:$MAX " # blue shoud work for most of the grabbers. But you can select RED by "print $1" or GREEN by "print $2" if [ "$MAX" -lt "$LIMIT" ] ; then echo "Killing the grabber!" for PID in $( ps -ef | grep -v grep | grep "$GRABBER" | grep "$GCONFIG" | awk '{ print $2 }' ) ; do kill $PID ; done else echo "OK" fi else echo "No grab available..." fi sleep 20s # 600s ?? done