Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/expect -f
- set timeout 5
- set load_fh [open "IPLIST.txt" r]
- set ip_list [split [read $load_fh] "\n"]
- close $load_fh
- # router user name
- set name "admin"
- # router password
- set pass "PASSWORD"
- # Read command as arg to this script
- set routercmd [lindex $argv 0]
- foreach ip $ip_list {
- if {$ip != ""} {
- send_user "telnet to this host: $ip\n"
- # Connect
- spawn telnet $ip
- # router user name
- set name "admin"
- # router password
- set pass "PASSWORD"
- # Read command as arg to this script
- set routercmd [lindex $argv 0]
- # send username & password
- expect "Login:"
- send -- "$name\r"
- expect "Password:"
- send -- "$pass\r"
- # Getting A Shell
- expect "Do you want to spawn a shell instead? (y/N)"
- send -- "y\r"
- # execute command , supposed we r using ash at aztech router
- expect "# "
- send -- "$routercmd\r"
- # exit
- }
- send_user "end processing host: $ip\n\n"
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement