Created
October 27, 2016 08:55
-
-
Save xianlubird/2beebc66311f3aa05243350db02ce3ab to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect -f | |
set timeout 20 | |
if { [llength $argv] < 1} { | |
puts "Usage:" | |
puts "$argv0 ip username passwd" | |
exit 1 | |
} | |
set ip [lindex $argv 0] | |
set username [lindex $argv 1] | |
set passwd [lindex $argv 2] | |
set passwderror 0 | |
spawn ssh $username@$ip | |
expect { | |
"*assword*" | |
{ | |
send "$passwd\n"; | |
} | |
"*es/no*" | |
{ | |
send "yes\n"; | |
exp_continue; | |
} | |
} | |
interact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment