All pastes #773453 Raw Edit

Something

public shellscript v1 · immutable
·published 2007-11-14 15:32 UTC
rendered paste body
while read channel qidletime; dodevice=`asterisk -rx "database showkey AMPUSER/${channel:6}/device" | grep -a device | cut -d":" -f2 | sed 's/ //g' `dial=`asterisk -rx "database showkey DEVICE/$device/dial" | grep -a dial | cut -d":" -f2 | sed 's/ //g' `lastactivity=`asterisk -rx "database showkey AMPUSER/${channel:6}/lastactivity" | grep -a ${channel:6} | cut -d":" -f2 | sed 's/ //g' `time=`date +%s`#echo $time#echo $lastactivity#echo $maxtime	# Member didnt recive a q call in the past maxtime, check the lastactivity and log him off	if (( qidletime >= maxtime )) && (( ((time - lastactivity)) >= maxtime )); then		logoff $channel $device;			echo "no call for $qidletime, lastactivity is $lastactivity"		exit		# Member didnt make a call in the past maxtime, check the qidletime and log him off	elif (( ((time - lastactivity)) >= maxtime )) && (( qidletime >= maxtime )); then			logoff $channel $device; 		fi			#echo "lastactivity is $(( $time - $lastactivity)), qidletime is $qidletime"		exit	#Member hasnt recived ANY q calls (so he has no qidletime), just check lastactivity and log him off	elif (( ((time - lastactivity)) >= maxtime )); then		logoff $channel $device; 	        fi		echo "no q calls, lastactivity is $(( $time - $lastactivity))"	#Do nothing	else		echo "nothing to do for Member $channel"done <<< "$qmembers"