当前位置:Gxlcms > Python > python远程登陆scp文件的方法教程

python远程登陆scp文件的方法教程

时间:2021-07-01 10:21:17 帮助过:57人阅读

这篇文章主要介绍了python 实现自动远程登陆scp文件实例代码的相关资料,需要的朋友可以参考下

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

实现实例代码:

  1. #!/usr/bin/expect
  2. if {$argc!=3} {
  3. send_user "Usage: $argv0 {path1} {path2} {Password}\n\n"
  4. exit
  5. }
  6. set path1 [lindex $argv 0]
  7. set path2 [lindex $argv 1]
  8. set Password [lindex $argv 2]
  9. spawn scp ${path1} ${path2}
  10. expect {
  11. "Password:" {
  12. exec sleep 1
  13. send "${Password}\r"
  14. }
  15. "*continue connecting*" {
  16. exec sleep 1
  17. send "yes\r"
  18. expect "*Password:" {
  19. exec sleep 1
  20. send "${Password}\r"
  21. }
  22. }
  23. }
  24. expect "*"
  25. send "exit\r"
  26. expect "*closed*"
  27. #send "exit\r"
  28. #expect "*"
  29. #exit
  30. #exec sleep 10

【相关推荐】

1. 特别推荐:“php程序员工具箱”V0.1版本下载

2. Python免费视频教程

3. Python基础入门教程

以上就是python 远程登陆scp文件的方法教程的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行