Tutorial on how to log in to scp files remotely using python

Y2J
Release: 2017-05-16 13:15:35
Original
2161 people have browsed it

This article mainly introduces the relevant information about the example code of python to realize automatic remote login to scp file. Friends who need it can refer to

python to realize automatic remote login to 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
Copy after login

[Related recommendations]

1. Special recommendation:"php Programmer Toolbox" V0.1 version download

2. Python free video tutorial

3. Python basic introductory tutorial

The above is the detailed content of Tutorial on how to log in to scp files remotely using python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template