Skip to content

Instantly share code, notes, and snippets.

@xianlubird
Created October 27, 2016 08:55
Show Gist options
  • Save xianlubird/2beebc66311f3aa05243350db02ce3ab to your computer and use it in GitHub Desktop.
Save xianlubird/2beebc66311f3aa05243350db02ce3ab to your computer and use it in GitHub Desktop.
#!/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