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

努力向前走一步,离梦想就更近一步。错过现在就等于糟蹋未来。生活就是那样,不留一丝余地,活下去似乎都需要很大的勇气。

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

实现实例代码:

#!/usr/bin/expect


if {$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 1
send "${Password}\r"
}
"*continue connecting*" {
exec sleep 1
send "yes\r"
expect "*Password:" {
exec sleep 1
send "${Password}\r"
}
 
}
}
expect "*" 
send "exit\r"
expect "*closed*"
#send "exit\r"
#expect "*"
#exit
#exec sleep 10

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

以上就是python 实现自动远程登陆scp文件实例代码。爱到最后,成全你的自由。更多关于python 实现自动远程登陆scp文件实例代码请关注haodaima.com其它相关文章!

标签: python scp