vagrant/script/hobo-ssh-expect.sh

24 lines
366 B
Bash
Raw Normal View History

2010-01-26 08:01:17 +00:00
#!/usr/bin/expect
set uname [lrange $argv 0 0]
set password [lrange $argv 1 1]
set host [lrange $argv 2 2]
2010-01-30 08:14:39 +00:00
set port [lrange $argv 3 3]
2010-01-26 08:01:17 +00:00
2010-01-30 08:14:39 +00:00
if { $port != "" } {
set port_option "-p $port"
} else {
set port_option ""
}
spawn ssh $port_option $uname@$host
2010-01-26 08:01:17 +00:00
expect "*password: " {
sleep 1
send "$password\r"
} timeout {
send_user "Error connecting"
}
interact