#!/bin/bash
#
#This script runs `ftp` in a terminal, with the argument given as a URL in the
#form ftp://<host>[:port] (no path is accepted)

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

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

ftp_args="`echo $1 | sed 's_ftp://__' | tr ':' ' '`"

exec x-terminal-emulator -e ftp $ftp_args
