Skip to content

Instantly share code, notes, and snippets.

@poppen
Created July 7, 2014 00:38
Show Gist options
  • Save poppen/b107bc1a898fcf51ec2c to your computer and use it in GitHub Desktop.
Save poppen/b107bc1a898fcf51ec2c to your computer and use it in GitHub Desktop.
clear dns cache script for yamaha routers
# -*- encoding: utf-8 -*-
# vim: set filetype=ruby expandtab tabstop=4 shiftwidth=4 autoindent smartindent:
require 'net/telnet'
require 'yaml'
routers = YAML.load_file(ARGV[0])
routers.each do |router|
begin
telnet = Net::Telnet.new("Host" => router)
telnet.waitfor(/Password:/)
telnet.puts(ARGV[1])
telnet.waitfor(/>/)
telnet.puts("administrator")
telnet.waitfor(/Password:/)
telnet.puts(ARGV[1])
telnet.waitfor(/#/)
telnet.puts("clear dns cache")
telnet.close
rescue Net::OpenTimeout => e
puts router
puts e
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment