#!/bin/csh -f

# This file copies data directories back to local host machine 
# from remote host machine. 

# NOTE: this is a blank shell script. You will need to input 
#       the correct variables for the specific machines.

if ( ${#argv} != 1 || ${1} == -h || ${1} == --help) then
    echo " "
    echo "  GETFILES "
    echo " "
    echo "  Copies data files from one machine to another "
    echo " "
    echo "  Useage: "
    echo " "
    echo "   getfiles {directory root name} "
    echo " "
    echo "   e.g.   getfiles 33245"
    echo " "
    echo "  written by Luke Abraham 2005/09/29 "
    echo " "
    echo " "
    exit 1
endif
 

# could be someing line ".{remote_host_name}/" on remote host
set dir_string= #userinput             

# name of directory data exists within on remote host
set send_dir=${1}${dir_string}

# name of remote host 
set from_machine= #userinput         

# root data directory on local host  
# e.g. data/  
set datadir= #userinput

# full path of directory to copy data into. The remote host is 
# added as a string after the ${1} string to prevent data from
# different machines being copied into the same folder.          
set to_dir=${HOME}/${datadir}${1}.${from_machine}/ 

# in case username on remote host is different from username
# on local host.
set from_user= #userinput

# root directory that contains ${send_dir} - this will probably
# be fixed on the remote machine. Needs to be full path, 
# i.e. /home/${from_user}/{dir}/ etc.
set from_machine_datadir= #userinput

# full path of usr@machine:datadir before send_dir is added
set from_machine_path=${from_user}@${from_machine}:${from_machine_datadir}

# just tell user what you are doing
echo "scp -r "$from_machine_path$send_dir $to_dir

# copy line
scp -r $from_machine_path$send_dir $to_dir