歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> Linux技術

CentOS6.5文件同步分發腳本

#!/bin/bash
   #push
   set -x
   ip1=xxx.xxx.xxx.xxx
   user1=root
   password1=root
   #----------------------
   ip2=xxx.xxx.xxx.xxx
   user2=root
   password2=password
   #-------------------
   source=/home/project/ORCA_WEB/target
   file=$(cd /home/project/ORCA_WEB/target;ls | grep ORCA_WEB*.war)
   echo ${file}
   
   #ssh -p 22 $user1@$ip1 'cd /home/orca/tmp; rm -rf *'
   #ssh -p 22 $user2@$ip2 'cd /home/orca/tmp; rm -rf *'
   
   cd ${source}
   
   ftp -niv <<- EOF
   open ${ip1}
   user ${user1} ${password1}
   $cd 
   bin
   put ${file} /home/orca/tmp/${file}
   bye
   EOF
   
   
   ftp -niv <<- EOF
   open ${ip2}
   user ${user2} ${password2}
   $cd 
   bin
   put ${file} /home/orca/tmp/${file}
   bye
   EOF
   
   #分發結束後,執行目標設備的腳本
   
   ssh -p 22 $user1@$ip1 'cd /home/orca/shell;bash ./replace.sh'
   ssh -p 22 $user2@$ip2 'cd /home/orca/shell;bash ./replace.sh'
Copyright © Linux教程網 All Rights Reserved