Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62831458
copy_from_scratch_to_UNIL_NAS.sh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, May 15, 23:17
Size
4 KB
Mime Type
text/x-shellscript
Expires
Fri, May 17, 23:17 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
17695413
Attached To
R9795 DCSR Cluster Examples
copy_from_scratch_to_UNIL_NAS.sh
View Options
#!/bin/bash
#
print_help
()
{
echo
"================================================================="
>&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
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!
# 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/<your_faculty/<your_department/<your_PI>/<your_project>"
echo
exit
1
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
Event Timeline
Log In to Comment