#!/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'