#!/bin/sh --

. /home/src/kqml/C/ver.2/bin/kqmlenv.sh

pgcmd=""

if [ "$1" = "-f" ]
then
	# Ensure that tail is available
	cat /dev/null | tail > /dev/null 2>&1
	if [ $? -eq 0 ]
	then
		pgcmd="tail -f"
	fi
	shift 1
else
	# Check if pg, less, more, cat is available
	if [ "$PAGER" = "" ]
	then
		for cmds in pg less more cat
		do
			cat /dev/null | ${cmds} > /dev/null 2>&1
			if [ $? -eq 0 ] 
			then
				pgcmd=${cmds}
				break
			fi
		done
	else
		cat /dev/null | $PAGER > /dev/null 2>&1
		if [ $? -eq 0 ]
		then
			pgcmd=$PAGER
		fi
	fi
fi

if [ "$pgcmd" = "" ]
then
	echo
	echo "Required/Suitable pager not found"
	exit 1
fi

if [ $? -eq 0 ]
then
	for agent in $*
	do
		$pgcmd $KQML_HOME/log/$agent.Kdbg
	done
fi
