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