#!/usr/bin/expect
set MYDATE [exec date +%F]
set passwd "678888"
set timeout 3600 --拷贝超时时间,注意根据文件大小设置
spawn scp 用户名@服务器ip:/data/backup/upload_$MYDATE.tar.gz
#目标地址
/data/backup/attachment
expect {
"密码:"
{
send "$passwd\n"
}
"pass"
{
send "$passwd\n"
}
"yes/no"
{
sleep 3
send_user "send yes"
send "yes\n"
}
eof
{
sleep 3
send_user "eof\n"
}
}
send "exit\r"
expect eof
linux环境下定时远程拷贝文件
最新推荐文章于 2022-08-05 14:52:40 发布