首页 > 开发 > Python > 正文

python 实现自动远程登陆scp文件实例代码

2024-09-09 19:02:08
字体:
来源:转载
供稿:网友

 python 实现自动远程登陆scp文件实例代码

实现实例代码:

#!/usr/bin/expectif {$argc!=3} {send_user "Usage: $argv0 {path1} {path2} {Password}/n/n"exit}set path1 [lindex $argv 0]set path2 [lindex $argv 1]set Password [lindex $argv 2]spawn scp ${path1} ${path2}expect {"Password:" {exec sleep 1send "${Password}/r"}"*continue connecting*" {exec sleep 1send "yes/r"expect "*Password:" {exec sleep 1send "${Password}/r"} }}expect "*" send "exit/r"expect "*closed*"#send "exit/r"#expect "*"#exit#exec sleep 10

感谢阅读,希望能帮助到大家,谢谢大家对本站的支持!

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表