无需手动输入密码,自动执行,传输指定目录的最新文件到指定服务器。
#!/usr/bin/expect
# 设置超时时间为无限制
set timeout -1
# 源服务器的密码
set src_password "12345789"
# 目标服务器的密码
set dest_password "12345789"
# 查找源主机上最新的文件
spawn ssh -o StrictHostKeyChecking=no [email protected] "ls -t /data/gbase_backup/ontape_L0* | head -1"
expect {