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'
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章