Each time on-line, first put the intranet code with Xhell to local. Then drag it to the online server.
Dragged and dragged, too slow. So I wrote an online script.
Wrote a few versions, this is the final version
scp_v3.sh
The contents are as follows:
#!/bin/bash
#注释
: <<block
Intranet project message, path is/message/trunk/..... File
The line path is/server/www/.... File
Then the mandate of the SCP is
Scp-r-P 22-r/message/trunk/..... File 192.168.1.110:/server/www/.... File
This script is to implement this SCP command, there are multiple files, loop execution.
The execution method is
./scp_sto_v3.sh/message/trunk/..... File
For example:
./scp_sto_v3.sh/message/trunk/kdcore/library/stosdk/providers/kuaidts.php /message/trunk/www/view/common/header.php
BLOCK
Echo-e "\033[31m only applies to message items, please know! \033[0m "
# Online to Online server
Case $* in
*)
#获取脚本后面输入的值, which is the absolute path to the local file
a=$*
echo "Project message online to Aliyun_sto" && read-n 1-p "Click Press any key to continue"
#判断参数的长度
Aa= ' echo ' $a | TR-CD "" | Wc-c '
#定义初始变量
I=1
#定义方法
function cc () {
#以空格为单位 to determine the length of the string after separation
Split= ' echo $a |cut-d ""-f$i "
#判断是否为空
If ["$split"! = ""]
Then
#自加一次
((i++))
#echo $split
#截取文件, get the project name
Pro= ' echo $split | Cut-d "/"-F 2 '
#判断是否属于message项目
If ["$pro"! = "message"];then
Echo-e "\033[31m $split non-message project, program exits \033[0m"
Exit
Fi
#截取线上服务器目录, exclude/server/www
B= ' echo ${split:18} '
#拼凑上线文件在远程服务器的绝对路径
C= ' echo ${b%/*} '
#创建线上服务器文件目录, whether or not it exists, creates
SSH [email protected] "Mkdir-p/server/www/$c"
#传输文件, separate to 2 servers
Scp-r-P 22-r $split 58.218.208.15:/server/www/$b
Else
Break
Fi
}
#判断变量长度, 0 means only one file
If ["$aa" = = 0];then
while (($i ==1))
Do
#执行cc方法
Cc
Done
Else
while ((1==1))
Do
Cc
Done
Fi
;;
Esac
This article is from the "Falling Star" blog, make sure to keep this source http://xiao987334176.blog.51cto.com/2202382/1710278
Shell Line Script