#! /bin/sh
#
# zfrom by sal valente <svalente@athena.mit.edu>

if [ "$#" != "2" ] ; then
        echo "Usage: zfrom [ +x | -x | destination ] instance"
        exit
fi

if  [ \! -d /mit/bitbucket/zephyr-log ] ; then
	attach bitbucket >/dev/null
fi

if [ -f /mit/bitbucket/zephyr-log/"$2" ] ; then

n=1

case "$1"
in
	-* | +* ) n="$1" ;;
	* ) n=+`fgrep -n "$1" /mit/bitbucket/zephyr-log/"$2" | tail -1 | \
	        /bin/awk -F: '{print $1}' ` ;;
esac

if [ "$n" != "+" ] ; then
        /usr/ucb/tail "$n" /mit/bitbucket/zephyr-log/"$2" > /tmp/zlog
        /usr/ucb/more /tmp/zlog
else
        echo "zfrom: $1: destination not found"
fi

else
        echo "zfrom: $2: log not found"
fi


