#!/bin/sh
#
# Copyright (c) 1997 S.u.S.E. GmbH Fuerth, Germany.
#
# Author: Werner Fink <werner@suse.de>
#

#
# Common programs and variables
#
if test -x /usr/bin/X11/xterm ; then
   term="/usr/bin/X11/xterm -ls"
else
   term="/usr/bin/xterm -ls"
fi
 telnet="telnet"
    # local xterm kbs
    kbs="`tput -Txterm kbs|sed -e 's@@^?@;s@@^H@'`"
    # common TERM because remote XTERM=xterm maybe differ
     tn="-tn vt100"
  quiet=""
#
# Usage
#
usage ()
{
    echo "$0: Usage" >&2
    echo "  $0 [-iconic] [-a] [-q] host [host ...]" >&2
    exit 1
}
#
# Parse options
#
while test -n "$1" ; do
    case $1 in
    -i|-iconic) iconic="-iconic" ; shift ;;
    -a)         telnet="telnet -a" ; shift ;;
    -s)         telnet="slogin" ; shift ;;
    -q)         quiet=true ; shift ;;
    -*)         usage ;;
    *)          hosts="$hosts $1" ; shift ;;
    esac
done
#
# And start the xterm
#
if [ -z "$quiet" ]; then
    echo "$0:
  If you have problems with the backspace key you should execute
  the command line:
	stty erase '$kbs'
  after successful login."
fi
for h in $hosts; do
    ${term} -T "telnet ${h}" -n ${h} ${iconic} ${tn} -tm "erase ${kbs}" \
    -e ${telnet} ${h} &
done

exit 0
