#!/bin/csh -f
# -----------------------------------------------------------------------------
#
# Name       : copy_to_output.csh
#
# Purpose    : Copy files to remote destination.
#
# Usage      : copy_to_output.csh <filename> <destination>
#
# Options    : None.
#
# Arguements : 
#              <filename>
#              <destination> = cdfdata@fcdfdata004.fnal.gov:snihur/foo
#                              If no colon ":" is found, 
#                              then assume destination is local directory.
#
# Created    : RMS20040606
# Updated    : RMS20050112 Allow local destination. 
#
# -----------------------------------------------------------------------------
echo $$ $0 $*
ls -l $1
if ( `echo $2 | grep -v ":"` == $2 ) then # Local if no colon in destination.
    #echo "local"
    cp $1 $2
    set rc = $status 
    exit $rc
endif

source ~cdfsoft/cdf2.cshrc
setup fcp
set rc = $status 
echo $rc
which fcp
set rc = $status 
echo $rc
if ( $rc != 0 ) then
	 source /local/ups/etc/setups.csh
	 setup fcp
	 set rc = $status 
	 echo $rc
	 which fcp
	 set rc = $status 
	 echo $rc
endif
if ( $rc != 0 ) then
	 source `${UPS_DIR}/bin/ups setup ups`
	 setup fcp
	 set rc = $status 
	 echo $rc
	 which fcp
	 set rc = $status 
	 echo $rc
endif
if ( $rc != 0 ) then
	 source /fnal/ups/etc/setups.csh
	 setup fcp
	 set rc = $status 
	 echo $rc
	 which fcp
	 set rc = $status 
	 echo $rc
endif
locate fcp
if ( $rc != 0 ) then
	 echo "No fcp"
	 exit $rc
endif

ls -l `which fcp`
fcp -c /usr/krb5/bin/rcp -N $1 $2
exit $status

