Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 16:50
Show Gist options
  • Save anonymous/4329647 to your computer and use it in GitHub Desktop.
Save anonymous/4329647 to your computer and use it in GitHub Desktop.
i = (name.count - 1)
begin
router_telnet_wrap = Net::SSH::Telnet.new(
"Dump_log" => "dump_log.txt",
"Host" => "#{ip.fetch(i)}",
"Username" => "#{login.fetch(i)}",
"Password" => "#{pw.fetch(i)}",
"Timeout" => 60,
"Prompt" => /#{prompt.fetch(i)}/
)
rescue
exit
rescue SystemCallError
exit
rescue TimeoutError
exit
rescue SocketError
exit
rescue Exception
exit
end
load_commands = []
load_commands = File.open("/var/www/alpha_rel_1/temp_files/#{name[i]}.txt").readlines.map(&:chomp)
puts load_commands
load_commands.each do |x|
@to_output = router_telnet_wrap.cmd(x)
puts @to_output
output_file = File.open("/var/www/alpha_rel_1/output/#{name[i]}-output-#{@tstamp}.txt", "a+")
output_file.write(@to_output)
output_file.close
end
i-=1
end while i > 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment