bwdatools/bwda

52 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
source $HOME/.bwda
# Usage function
usage(){
echo "Usage: $(basename $0) [opt] [path]"
echo "Opens an interactive lftp session on bwDataArchive."
echo " path directory on LSDF, session will cd to the corresponding bwda directory"
echo " -h | --help display this message"
}
# Get command line argument
nparallel=1
nchannel=1
flag_printcommands=false
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
usage
exit 0
shift
;;
*)
POSITIONAL+=("$1")
shift
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [ $# -eq 0 ]; then
lftp sftp://${bwda_acc}@${bwda_url}
else
ldir_target="$(realpath $1)"
# Get current path relative to base
if [[ $ldir_target == "${ldir_base}"* ]]; then
dir_target=${ldir_target#"$ldir_base"}
else
echo "Target directory is not located on LSDF!"
echo "Is the base directory setting correct?"
echo "ldir_base: $ldir_base"
exit -1
fi
rdir_target="${rdir_base}/${dir_target}"
lftp sftp://${bwda_acc}@${bwda_url} -e "cd $rdir_target"
fi