#! /bin/bash
Action () {
#1, get SVN update output
/OPT/SVN/SVN/BIN/SVN update/opt/lampz/apache/web > File_out
#2, gets the number of rows through the output file File_out
line=$ (wc-l File_out|awk ' {print $} ')
#3, if the number of rows is greater than 2, there is an update or delete operation to get a list of files that need to be deleted or updated
if [[$line > 2]];then
Egrep-v ' Updating| updated| At ' file_out|egrep ' ^d ' |awk ' {print $} ' |awk-f ' web ' {print $} ' >file_delete #删除的文件列表
Egrep-v ' Updating| updated| At ' file_out|egrep-v ' D ' |awk ' {print $} ' >file_update #更新的文件列表
echo "Yes"
Else
echo "No Update"
Fi
#4, delete according to the File_delete file
For Del in $ (cat file_delete)
Do
/opt/ncftp3.2.5/bin/ncftp rm-u wangtao-p wt123321-p 62256 ${del#*web}
Done
#5, update operations based on the File_update file
For Update in $ (cat file_update)
Do
Path=${update#*web}
/opt/ncftp3.2.5/bin/ncftpput-u wangtao-p wt123321-p 62256 182.92.150.109/${path%/*} $Update
Done
}
while ((1))
Do
Action
Sleep 1
Done
SVN sync to FTP shell script