python implementation of automatic remote login scp file instance code

  • 2020-05-26 09:38:11
  • OfStack

python implements automatic remote login scp file instance code

Implementation example code:


#!/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

Thank you for reading, I hope to help you, thank you for your support of this site!


Related articles: