#!/bin/bash #GetPath.sh #用途:获取某天到某天,某个时间段的数据路径 #路径输出到path.txt文件中 ###################StepOne.#################### >path.txt functiontraceInfoWriter { echo-e"\033[40m\033[1;36m"$*"\033[0m" } functionusage { traceInfoWriter"Usage:" traceInfoWriter"$0-ddate-{例:20170101-20171231}--hhour-{例:00-24}-" traceInfoWriter"-d:daterange.(20170101-20171231)" traceInfoWriter"-h:hourrange.(00-24)" traceInfoWriter"-H:helpinfo" traceInfoWriter"Example:sh$0-d20170501-20170612-h02-08" exit } [[0-eq$#]]&&usage whilegetopts"d:h:H"ARG do case$ARGin d) exportDate=$OPTARG ;; h) exportHour=$OPTARG ;; H) usage ;; ?) echo"Unkonwargument!" echo"Only-d-h-Hoptionsaresupported~" exit1 esac done stime=${Date:0:8} etime=${Date:9:17} sh=${Hour%-*} eh=${Hour##*-} if[[$stime-gt$etime]]||[[$sh-gt$eh]] then echo"Errorformat." exit1 fi while: do foriin`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.txt2>/dev/null done stime=$(date-d"$stime1day"+%Y%m%d) if[[$stime-gt$etime]];then break; fi done
第二部分:通过scp传输数据@H_403_4@
#!/bin/bash #TransferData.sh #读取path.txt文件传输数据 #remotepath目标服务器路径 ##################StepTwo################# user=gsics host=10.24.173.162 passwd=gsics03 remotepath="/home/gsics/user/wangp/data" forfilepathin`catpath.txt` do expect-c" settimeout30 spawnscp$filepath$user@$host:${remotepath} expect{ \"*yes/no\"{send\"yes\r\";exp_continue} \"*?assword:\"{send\"$passwd\r\"} } interact " done