#!/bin/bash

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

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

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

dmd5620_args="`echo $1 | sed 's,telnet_5620://,-h ,' | sed 's/:/ -p /'`"

exec dmd5620 $dmd5620_args
