«

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

时间:2024-3-2 12:47     作者:韩俊     分类: Python


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

实现实例代码:

#!/usr/bin/expect

if {$argc!=3} {
send_user "Usage: $argv0 {path1} {path2} {Password}nn"
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 "yesr"
expect "*Password:" {
exec sleep 1
send "${Password}r"
}

}
}
expect "*" 
send "exitr"
expect "*closed*"
#send "exitr"
#expect "*"
#exit
#exec sleep 10

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

标签: python

热门推荐