Advertisement
theillien

Untitled

Sep 6th, 2013
303
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
TCL 0.89 KB | None | 0 0
  1. set prompt {\$ $}
  2. set file1 [open [lindex $argv 0] r]
  3. set pw1 [exec cat /home/msnyder/bin/.pw1.txt]
  4. set pw2 [exec cat /home/msnyder/bin/.pw2.txt]
  5.  
  6. while {[gets $file1 host] != -1} {
  7.     puts $host
  8.     spawn -noecho ssh $host
  9.     expect {
  10.         "continue connecting" {
  11.             send "yes\r"
  12.             expect {
  13.                 "current" {
  14.                     send -- $pw2\r
  15.                     exp_continue
  16.                 }
  17.                 "New password" {
  18.                     send -- $pw1\r
  19.                     exp_continue
  20.                 }
  21.                 "Retype new password" {
  22.                     send -- $pw1\r
  23.                     exp_continue
  24.                     -re $prompt   # I'm not sure about this one. Does it belong here? This is where you put it.
  25.                 }
  26.             }
  27.             -re $prompt
  28.         }
  29.         send -- exit\r
  30.         expect eof
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement