Home >Backend Development >Python Tutorial >Tutorial on how to log in to scp files remotely using python

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

Y2J
Y2JOriginal
2017-05-16 13:15:352184browse

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

[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!

Statement:
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