#!/bin/bash

#This script opens a telnet connection in the default X11 terminal emulator. The
#URL is in the usual telnet://<host>[:<port>] format.

if [ ! "$1" ]
then
	echo "no URL provided" >&2
	exit 1
fi

if ! echo "$1" | grep -q '^telnet://'
then
	echo "URL does not start with telnet://" >&2
	exit 1
fi

telnet_args="`echo $1 | sed 's_telnet://__' | tr ':' ' '`"

exec x-terminal-emulator -e telnet $telnet_args
