python 实现自动远程登陆scp文件实例代码
实现实例代码:
#!/usr/bin/expect
if {$argc!=3} {
send_user "Usage: $argv0 {path1} {path2} {Password}
"
exit
}
set path1 [lindex $argv 0]
set path2 [lindex $argv 1]
set Password [lindex $argv 2]
spawn scp ${path1} ${path2}
expect {
"Password:" {
exec sleep 1
send "${Password}
"
}
"*continue connecting*" {
exec sleep 1
send "yes
"
expect "*Password:" {
exec sleep 1
send "${Password}
"
}
}
}
expect "*"
send "exit
"
expect "*closed*"
#send "exit
"
#expect "*"
#exit
#exec sleep 10【相关推荐】
1. 特别推荐:“php程序员工具箱”V0.1版本下载
2. Python免费视频教程
3. Python基础入门教程