Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/expect
- log_file switches.log
- set command "show unit"
- set prompt "#"
- set password "password"
- set switches [list 8.8.8.8 8.8.4.4]
- package require Expect
- foreach ip $switches {
- puts $ip
- spawn telnet $ip
- set timeout 3
- expect Username:
- send admin\r
- expect Password:
- send $password\r
- expect -exact $prompt
- send "$command\r"
- expect -exact $prompt
- send exit\r
- }
- # then we can extract all SN with: grep -o '\bRZ\w*' switches.log
Add Comment
Please, Sign In to add comment