18,777
社区成员
发帖
与我相关
我的任务
分享
#!/usr/bin/expect -f
set ip [lindex $argv 0 ]
set username [lindex $argv 1 ]
set password [lindex $argv 2 ]
set sourcepath [lindex $argv 3 ]
set destpath [lindex $argv 4 ]
set timeout 10
spawn scp $username@$ip:$sourcepath $destpath
expect {
"*yes/no" { send "yes\r"; exp_continue}
"*password:" { send "$password\r" }
}
interact
假设上面这个脚本叫auto_scp, 放在当前目录
则用法为./auto_scp 远程ip 远程用户名 远程密码 远程文件路径 本机目的路径