Posted to tcl by urthmover at Mon Aug 08 15:01:59 GMT 2011view raw
- #!/usr/bin/expect
-
- set f [open hosts.lst r]; # open the file
- set data [read $f]; # read the file content
- close $f; # close the file
- foreach line [split $data \n] { ;# starts a loop over the lines
- if {$line eq {}} continue; # ignore blank lines
- set user root
- set oldpassword abcdefg
- set newpassword 1234567
- set cmd "passwd root"
- spawn ssh -n $user@$line
-
- expect "*?ssword:*"
- send -- "$oldpassword\r"
-
- send -- "$cmd\r"
- expect "*?ssword:*"
- send -- "$newpassword\r"
- expect "*?ssword:*"
- send -- "$newpassword\r"
-
- send -- "exit\r"
- send -- "\r"
-
- expect eof;
- }