Guest User

Untitled

a guest
Sep 3rd, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #!/usr/bin/expect
  2. log_file switches.log
  3.  
  4. set command "show unit"
  5. set prompt "#"
  6. set password "password"
  7. set switches [list 8.8.8.8 8.8.4.4]
  8.  
  9. package require Expect
  10.  
  11. foreach ip $switches {
  12. puts $ip
  13.  
  14. spawn telnet $ip
  15. set timeout 3
  16.  
  17. expect Username:
  18. send admin\r
  19.  
  20. expect Password:
  21. send $password\r
  22.  
  23. expect -exact $prompt
  24. send "$command\r"
  25.  
  26. expect -exact $prompt
  27. send exit\r
  28. }
  29.  
  30. # then we can extract all SN with: grep -o '\bRZ\w*' switches.log
Add Comment
Please, Sign In to add comment