#!/bin/sh
#
#  eline: terminal line supplier for EGTS (UNIX version)

	usage="eline"

# 	try to obtain physical line information (of the form host:ttydN)
#	for the users' terminal

#	version control:
#	===============
#  	V1.0  KH 22-mar-90:	initial version
#  	V1.1  KH 23-dec-93:	send warnings to stderr, not stdout
#  	V1.2  KH 26-jan-94:	shut up warning 'cannot determine...' -- too disturbing

#	note:
#	====
#	"eline" uses the "rwho" daemon to determine physical line information
#	when terminals are connected over ethernet networks to remote hosts.
#	It is supposed that all information about other machines, required
#	by "rwho" daemons, is available.

myname=`who am i | /usr/bin/cut -f1 -d" " `

# see whether logged into local machine

mytty=`who am i | grep ttyd | /usr/bin/cut -c12-24  `
if [ $mytty ]
then
	echo `hostname`\:$mytty
	exit
fi

# try remote machine

myttys=`rwho | grep ttyd | grep $myname | tr -s " " " " | /usr/bin/cut -f2 -d " " `
howmanyttys=`echo $myttys | wc -w `
case $howmanyttys in
	*0)	:;;
#	*0)	echo $0: warning: cannot determine your tty >&2;;
	*1)	echo $myttys; exit;;
	*)	echo $0: warning: no unique tty can be found \($myttys\) >&2;;
esac
echo none
exit
