Advertisement
Guest User

Untitled

a guest
Sep 17th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. #!/usr/bin/expect -f
  2.  
  3. set timeout 5
  4.  
  5. set load_fh [open "IPLIST.txt" r]
  6. set ip_list [split [read $load_fh] "\n"]
  7. close $load_fh
  8.  
  9. # router user name
  10. set name "admin"
  11.  
  12. # router password
  13. set pass "PASSWORD"
  14.  
  15. # Read command as arg to this script
  16. set routercmd [lindex $argv 0]
  17.  
  18. foreach ip $ip_list {
  19. if {$ip != ""} {
  20. send_user "telnet to this host: $ip\n"
  21.  
  22. # Connect
  23. spawn telnet $ip
  24.  
  25. # router user name
  26. set name "admin"
  27.  
  28. # router password
  29. set pass "PASSWORD"
  30.  
  31. # Read command as arg to this script
  32. set routercmd [lindex $argv 0]
  33.  
  34. # send username & password
  35. expect "Login:"
  36. send -- "$name\r"
  37. expect "Password:"
  38. send -- "$pass\r"
  39.  
  40. # Getting A Shell
  41. expect "Do you want to spawn a shell instead? (y/N)"
  42. send -- "y\r"
  43.  
  44. # execute command , supposed we r using ash at aztech router
  45. expect "# "
  46. send -- "$routercmd\r"
  47. # exit
  48. }
  49. send_user "end processing host: $ip\n\n"
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement