目标服务器需要先开通发送服务器的ip访问权限和22的ssh权限
#echo "资源打包结束,开始上传文件"
/usr/bin/expect << EOF
set timeout 3600
spawn scp -r /root/dist [email protected]:/home/web/html/static/app
expect {
"(yes/no)?" {
send "yes\n"
expect "*assword:" { send "123456\n"}
}
"*assword:" {
send "123456\n"
}
}
expect "100%"
expect "exit\n"
expect eof
EOF
#删除远程文件数据
/usr/bin/expect << EOF
set timeout 3600
spawn ssh [email protected] rm /home/web/html/static/app/*
expect {
"(yes/no)?" {
send "yes\n"
expect "*assword:" { send "123456\n"}
}
"*assword:" {
send "123456\n"
}
}
expect "100%"
expect "exit\n"
expect eof
EOF
echo "静态页面上传完成"
exit
原文地址:https://www.cnblogs.com/hr-cmbc/p/11494375.html
时间: 2024-10-12 02:27:31