Skip to content

Instantly share code, notes, and snippets.

@daqing
Created May 6, 2010 06:45
Show Gist options
  • Save daqing/391869 to your computer and use it in GitHub Desktop.
Save daqing/391869 to your computer and use it in GitHub Desktop.
auto login different hosts using expect
#!/usr/bin/expect -f
array set d {
141 "abc"
142 "foobar"
145 "buz"
}
if { $argc != 1 } {
puts "usage: $argv0 HOST"
puts "HOST can be 195 or 201"
return
}
set host [lindex $argv 0]
puts "host is: $host"
set password $d($host)
set timeout -1
spawn ssh root@192.168.0.$host
expect "*?assword:*"
send "$password\r"
interact
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment