#!/bin/bash unqarg=` echo $1 | sed -e 's/"//g'` #echo $unqarg cat /var/lib/asterisk/disa/list-usergroup1|grep -sw $unqarg >& /dev/null #looks up if the number exists in list-usergroup1 ERG=$? #is "0" if number exists, "1" if it doesn't exist #echo var: $ERG echo "SET VARIABLE ERG $ERG" checkresults() { while read line do case ${line:0:4} in "200 " ) echo $line >&2 return;; "510 " ) echo $line >&2 return;; "520 " ) echo $line >&2 return;; * ) echo $line >&2;; #keep on reading those Invlid command #command syntax until "520 End ..." esac done } checkresults