-
Notifications
You must be signed in to change notification settings - Fork 42
/
GEO_upload.sh
executable file
·87 lines (74 loc) · 1.28 KB
/
GEO_upload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#set -x
set -e
set -u
usage()
{
cat <<EOF >&2
${txtcyn}
Usage:
$0 options${txtrst}
${bldblu}Function${txtrst}:
This script is used to upload files to an FTP server using lftp.
${txtbld}OPTIONS${txtrst}:
-f FTP address ${bldred}[NECESSARY]${txtrst}
-u User name ${bldred}[NECESSARY]${txtrst}
-p Password ${bldred}[NECESSARY]${txtrst}
-t Target dir ${bldred}[NECESSARY, for GEO in format like
<fasp/GEO_metadata_zhaohui>]${txtrst}
-s Source dir ${bldred}[NECESSARY, default current directory]${txtrst}
-r Send success information to given email.
${bldred}[OPTIONAL, default chentong_biology@163.com]${txtrst}
EOF
}
ftp=
user=
passwd=
target=
source_dir="."
email="chentong_biology@163.com"
while getopts "hf:u:p:t:s:r:" OPTION
do
case $OPTION in
h)
usage
exit 1
;;
f)
ftp=$OPTARG
;;
u)
user=$OPTARG
;;
p)
passwd=$OPTARG
;;
t)
target=$OPTARG
;;
s)
source_dir=$OPTARG
;;
r)
email=$OPTARG
;;
?)
usage
exit 1
;;
esac
done
if [ -z $ftp ]; then
usage
exit 1
fi
cat <<END >lftp.script
open -u ${user},${passwd} ${ftp}
mkdir -p ${target}
cd ${target}
cache size 33554432
set cmd:parallel 10
mput -c ${source_dir}/*
END
lftp -f lftp.script
pythonmail3.py -r ${email} -s "${target} FINISHED"