diff --git a/cluster_basic/copy_from_scratch_to_UNIL_NAS.sh b/cluster_basic/copy_from_scratch_to_UNIL_NAS.sh index c1f587f..9692097 100755 --- a/cluster_basic/copy_from_scratch_to_UNIL_NAS.sh +++ b/cluster_basic/copy_from_scratch_to_UNIL_NAS.sh @@ -1,120 +1,124 @@ #!/bin/bash # print_help() { echo "=================================================================" >&2 - echo " " >&2 + echo " DCSR, University of Lausanne " >&2 + echo " " >&2 echo "Usage : sh $0 " >&2 echo " " >&2 echo "Purpose: shows how to use movedat to transfer a file or " >&2 echo " a directory to a remote directory in the UNIL NAS. " >&2 echo " shows how to use movedat to list remote content. " >&2 echo " " >&2 echo "To do : adapt \$SCRATCH_DIR in STEP 1 to point to your scratch " >&2 echo " directory " >&2 echo " " >&2 echo "=================================================================" >&2 exit 1 } - # Check command line options # -------------------------- if [ "$#" == "1" ]; then if [ "$1" == "-h" ] || [ "$1" == "--help" ]; then $(print_help) else echo; echo "FATAL: only accepted options are -h and --help."; echo - exit 1 fi + exit 1 fi if [ "$#" -ge "2" ]; then echo; echo "FATAL: only accepts a single option (-h or --help)"; echo exit 1 fi # Do not change the following definitions! -# ---------------------------------------- +# ---------------------------------------- SERVER=dexwin.unil.ch # Do not change! FILENAME=LocalFile_$USER.txt # Do not change! DIRNAME=LocalDir_$USER # Do not change! REMOTE_DIR=CTR/CI/DCSR/rfabbret/test_movedat/D2c/Course # Do not change! CLUSTER=wally # STEP 1: Adapt $SCRATCH_DIR to point to your scratch directory # ------------------------------------------------------------- SCRATCH_DIR=/scratch/$CLUSTER/CTR/CI/DCSR/rfabbret/test_movedat # Adapt! +echo -e "\nSTEP 1: \$SCRATCH_DIR set to: $SCRATCH_DIR"; echo # STEP 2: Check that $SCRATCH_DIR actually exists! # ------------------------------------------------ if [ ! -d $SCRATCH_DIR ]; then echo echo "FATAL: destination folder ($SCRATCH_DIR) does not exist!" echo " Please adapt \$SCRATCH_DIR to point towards your scratch directory" echo " SCRATCH_DIR=/scratch/\$CLUSTER/FAC//" echo exit 1 +else + echo; echo -e "STEP 2: all good, \$SCRATCH_DIR ($SCRATCH_DIR) is an existing directory!"; + echo; echo fi -echo + # STEP 3: List the content of $SCRATCH_DIR # ---------------------------------------- echo "STEP 3: Listing the content of $SCRATCH_DIR:" ls -rtl $SCRATCH_DIR echo; echo # STEP 4: Create a dummy file to copy to UNIL NAS # ----------------------------------------------- echo "I am $USER's dummy file." > $SCRATCH_DIR/$FILENAME echo "STEP 4: Created file: $SCRATCH_DIR/$FILENAME" echo " Use the following command to display its content:" echo " cat $SCRATCH_DIR/$FILENAME" echo; echo # STEP 5: Copy file $FILENAME from your scratch directory to UNIL NAS, keeping the same name # ------------------------------------------------------------------------------------------ echo "STEP 5: using movedat to copy $SCRATCH_DIR/$FILENAME to UNIL NAS (keeping the name)" movedat $SCRATCH_DIR/$FILENAME $USER@$SERVER:$REMOTE_DIR/ # To copy with same name echo; echo # STEP 6: Copy file $FILENAME from your scratch directory to UNIL NAS, keeping the same name # ------------------------------------------------------------------------------------------ echo "STEP 6: using movedat to copy $SCRATCH_DIR/$FILENAME to UNIL NAS, renaming the file" movedat $SCRATCH_DIR/$FILENAME $USER@$SERVER:$REMOTE_DIR/${FILENAME}_renamed # To rename the copied file echo; echo # STEP 7: List content of remote directory on UNIL NAS # ---------------------------------------------------- echo "STEP 7: Listing the content of remote directory $REMOTE_DIR/" movedat $USER@$SERVER:$REMOTE_DIR/ # Must be ending by "/" echo; echo # STEP 8: Create a small directory structure # ------------------------------------------ echo "STEP 8: Creating a small directory structure" mkdir -pv $SCRATCH_DIR/$DIRNAME/Subdir1/Subdir2 echo tree $SCRATCH_DIR/$DIRNAME/ echo; echo # STEP 9: Copy the directory structure $DIRNAME from your scratch to the UNIL NAS # Note: with '-h' option you copy file-by-file # with '-i' option you enable streaming mode # Note: the remote directory has to exist before you can put content in! # ------------------------------------------------------------------------------ movedat -n $USER@$SERVER:$REMOTE_DIR/$DIRNAME # Create the destination directory first echo movedat -h $SCRATCH_DIR/$DIRNAME $USER@$SERVER:$REMOTE_DIR/$DIRNAME # Copy the content echo; echo