#!/bin/csh -f

# Simulate result of "event route show -instance" since I already have these results cached.

# daw; 5/14/19

switch (`uname -s``uname -r`)
case SunOS5*:
    set TAILP = "+"
	breaksw
case Linux*:
    set TAILP = "--lines=+"
	breaksw
default:
	exec echo ${0}: does not run on `uname -s` `uname -r`
endsw

while($#argv)
	switch ("$1")
	case -d:
		set DEBUG
#		shift
#		breaksw
# fall through to verbose
	case -v:
		set VERBOSE
		shift
		breaksw
	default:
	    if (! $?MSGNAME) then
		set MSGNAME = $1
		shift
		breaksw
	    endif
		set DQ = '"'
		exec echo ${0}: "What do I do with $DQ$1$DQ?"
	endsw
end

if (! $?MSGNAME) exec echo what is the message name\?

set DQ = '"'
#set ERSI = ~watrous/Koko.lcsr/event.route.show-instance
set ERSI = /koko/var/cron-user/Koko.lcsr/event.route.show-instance

set LINENO = `grep -n $MSGNAME'$' $ERSI | sed 's;:.*;;'`

if ("$LINENO" == "") exec echo $DQ$MSGNAME$DQ not found

tail $TAILP$LINENO $ERSI |& \
    awk '{if(NF==0)exit;print}' | \
    fold -s
