Created
May 6, 2010 06:45
-
-
Save daqing/391869 to your computer and use it in GitHub Desktop.
auto login different hosts using expect
This file contains 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 | |
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