#!/bin/sh
#
# Copyright (c) 2002 by James A. McQuillan (McQuillan Systems, LLC)
#
# This software is licensed under the Gnu General Public License version 2,
# the full text of which can be found in the COPYING file.
#
#
# Enter a loop, running telnet to the server.
#

if [ $# -ne 1 ]; then
    echo "Usage:  $0 <hostname or ip addr>"
    exit 1
fi

#
# Set the terminal type, so that the remote host will
# have a clue what kind of terminal you are using.
#
export TERM=linux               # Setup the terminal type

#
# Get this terminal name, to display on the top line of the screen
#
TTY=`/usr/bin/basename \`/usr/bin/tty\``
[ "${TTY}" = "console" ] && TTY="tty1"    # Special case for first screen

REMOTE=$1

while :; do
    #
    # Clear the screen, to place cursor at the top
    #
    /usr/bin/clear

    #
    # Echo this message, telling user how to proceed.
    #
    echo -n "${TTY}, Press <enter> to establish a connection to the server..."
    read CMD

    #
    # Clear the screen before launching telnet
    #
    /usr/bin/clear

    #
    # Launch the telnet program.
    #
    /usr/bin/telnet ${REMOTE}

    #
    # Brief pause, incase telnet had errors to report
    #
    /bin/sleep 2
done
