自动scp(二)

#!/usr/bin/expect -f
spawn scp /shell/bms3acount.txt root@192.168.35.186:/root/BMS/
set timeout 20
expect "(yes/no)?" {
send "yes "}
expect "password:" {
send  "3344134 " }
expect eof

#!/usr/bin/expect -f
set timeout 36000
set password tysxtv189
#download
set date [exec date "+%Y-%m"]
spawn scp -l 30000 -P 6022 /data/messlog/backup/msg_$date.txt  datacenter@192.168.40.125:/data/ftpsite/duanxin/
#sleep 3600
expect {
"(yes/no)?"
{send "yes "}

"password:"
{send "$password "}
}

expect eof
exit

原文地址:https://www.cnblogs.com/lubing666666/p/4481931.html