#!/bin/sh -f
#
# Usage: srm-get-turl (get|put) <path> <user> <proto> ...
#

headnode="rip3.fnal.gov"

dir="$1"
path="$2"
eval user=$3

echo `date` "  " $dir $path $user >> /tmp/srm-get-turl.out

shift
shift
shift

proto=""
port=""
done="no"

#echo $dir $path $user $1 $2

while [ "$done" = "no" -a ! -z "$1" ]
do
	#echo try $1
	case "$1" in
		dfarm)	proto="dfarm"	# we prefer native protocol over anything else
				done="yes"
				;;
		gsiftp) proto=$1
			port=":2812"
				;;
	esac
	shift
done

if [ -z "$proto" ]
then
	exit 1
fi

if [ ! -z "$user" ]
then
	user="${user}@"
fi

echo "${proto}://${user}${headnode}${port}/${path}"
