+
+local pending_ses=${SES}
+local registered=false
+while [ "x${pending_ses}" != "x" ]
+do
+ #select a se from list
+ local S=`echo ${pending_ses} | awk '{print $1}'`
+ #update list of SEs
+ local new_list=""
+ for i in `echo ${pending_ses}`
+ do
+ if [ "$i" != "${S}" ]
+ then
+ new_list="${new_list} ${i}"
+ fi
+ done
+ pending_ses=${new_list}
+ local TEMP=`mktemp lcg-XXXXX`
+ if [ "${registered}" = "false" ]
+ then
+ echo -n "Registering release to ${S}..."
+ lcg-cr -v -d ${S} -l "lfn:${destlfn}" "file:${sourcefile}" &>${TEMP}
+ if [ $? != 0 ]
+ then
+ echo -e "\t [\033[31m FAILED \033[0m]"
+ cat ${TEMP}
+ \rm ${TEMP}
+ else
+ echo -e "\t [\033[32m OK \033[0m]"
+ registered=true
+ \rm ${TEMP}
+ fi
+ else
+ echo -n "Replicating release to ${S}..."
+ lcg-rep -v -d ${S} "lfn:${destlfn}" &>${TEMP}
+ if [ $? != 0 ]
+ then
+ echo -e "\t [\033[31m FAILED \033[0m]"
+ cat ${TEMP}
+ \rm ${TEMP}
+ else
+ echo -e "\t [\033[32m OK \033[0m]"
+ \rm ${TEMP}
+ fi
+ fi
+done