#!/bin/sh -

if [ "$1" = "" ] ; then
  echo -n "Host: "
  read host
else
  host="$1"
fi

if [ "$2" = "" ] ; then
  echo -n "User: "
  read user
else
  user="$2"
fi

if [ "$3" = "" ] ; then
  echo -n "XHost? [n] "
  read xhostp
else
  xhostp="$3"
fi

if [ `echo ${xhostp}x|sed -e 's/[Yy].*/y/'` = "y" ];then
	xhost $host
fi

if [ ! "$4" = "nil" ] ; then
  finger @$host
  echo 
  echo "-waiting-"
  read dummy
fi

case $user in
news|root)
    ;;
"$USER"|*)
    rkinit $host -l $user
    rsh $host /bin/athena/attach $user
    ;;
esac
rlogin $host -x -l $user
