shell通过scp命令实现简单数据推送
2017-06-16 14:30
686 查看
第一部分:获取数据路径
#!/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传输数据
#!/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
相关文章推荐
- 通过scp命令下载备份文件的shell脚本实现——使用sshpass
- 页面上一段时间内通过ajax轮询后台数据的简单实现方法
- shell 中cp命令的简单实现(未考虑复制后文件的权限)
- Shell中使用scp命令实现文件上传代码
- 简单通过java的socket&serversocket以及多线程技术实现多客户端的数据的传输,并将数据写入hbase中
- Linux通过命令使用UDP推送数据
- iOS通过NSUserDefaults实现简单的应用间数据传递
- 用tar命令简单实现数据的全备份、增量备份、差量备份
- java实现shell命令--小程序(通过Runtime和Process实现)
- shell 之 tee 命令,实现重定向到文件的同时仍能 通过管道 (|)传给接下来的命令
- 通过shell命令提取文件内容(C实现)
- 二十. 通过管道组合Shell命令获取系统运行数据:
- MongoDB_03之使用shell命令实现对文档数据的操作
- 推荐给初学者:通过ODBC?JDBC和SQL专用JDBC驱动实现简单的数据?
- ssh结合tar命令把远程文件拉回来或推过去(实现数据无落地推送)
- .net 通过URL推送POST数据具体实现
- 通过定时器将数据推送给表格,实现数据刷新的
- 用tar命令简单实现数据的全备份、增量备份、差量备份
- 无需密码通过scp命令+key的方式实现文件传输
- 通过广播实现简单数据交换前后台数据交换BroadcastReceiver