更新时间:2022-08-20 17:23:29
第一部分:获取数据路径
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
|
#!/bin/bash #GetPath.sh #用途:获取某天到某天,某个时间段的数据路径 #路径输出到path.txt文件中 ###################Step One.#################### >path.txt function traceInfoWriter
{ echo -e "\033[40m\033[1;36m" $* "\033[0m"
} function usage
{ traceInfoWriter "Usage:"
traceInfoWriter "$0 -d date -{例:20170101-20171231}- -h hour -{例:00-24}-"
traceInfoWriter "-d: date range.(20170101-20171231) "
traceInfoWriter "-h: hour range.(00-24)"
traceInfoWriter "-H: help info"
traceInfoWriter "Example: sh $0 -d 20170501-20170612 -h 02-08"
exit } [[ 0 - eq $ # ]] && usage
while getopts "d:h:H" ARG
do case $ARG in
d)
export Date=$OPTARG
;; h)
export Hour=$OPTARG
;; H)
usage
;; ?)
echo "Unkonw argument!"
echo "Only -d -h -H options are supported~"
exit 1
esac
done stime=${Date:0:8} etime=${Date:9:17} sh=${Hour%-*} eh=${Hour ##*-}
if [[ $stime -gt $etime ]] || [[ $sh -gt $eh ]]
then echo "Error format."
exit 1
fi while :
do for i in ` seq -s " " -w $sh $eh`
do ls /FY4/FY4A/AGRI/L1/FDI/DISK/2017/ $stime /FY4A-_AGRI--_N_DISK_ *E_L1-_*-_MULT_NOM_${stime}${i}*_*_4000M_V0001.HDF >> path2.txt 2> /dev/null
done stime=$( date -d "$stime 1day" +%Y%m%d)
if [[ $stime -gt $etime ]]; then
break ;
fi done |
第二部分:通过scp传输数据
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
#!/bin/bash #TransferData.sh #读取path.txt文件传输数据 #remotepath目标服务器路径 ##################Step Two################# user=gsics host=10.24.173.162 passwd =gsics03
remotepath= "/home/gsics/user/wangp/data"
for filepath in ` cat path.txt`
do expect -c " set timeout 30
spawn scp $filepath $user@$host:${remotepath}
expect {
\"* yes /no \" { send \" yes \r\"; exp_continue }
\"*?assword:\" { send \"$ passwd \r\" }
}
interact " done |