Skip to content

Instantly share code, notes, and snippets.

@nanotechz9l
Created April 13, 2016 19:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nanotechz9l/8a30a0d2fa3e4e595a335ae549cd2db4 to your computer and use it in GitHub Desktop.
Save nanotechz9l/8a30a0d2fa3e4e595a335ae549cd2db4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require '/root/Desktop/juniper_hash.rb';#require 'sugar'
# Parser script for Sweet tooth!
# DL juniper_hash.rb: https://github.com/sventantau/juniper_hash/blob/master/juniper_hash.rb
begin
unless ARGV.length == 1
puts "Doh! - Missing arguments. A Juniper FW config file must be given as an ARGV! Correct usage below:"#.foreground(:yellow).bright
puts "\n#{$0} juniper_fw.conf\n"#.foreground(:white).bright
#exit
end
file = ARGV[0]
hash_config = JuniperHash.get_hash(File.open(ARGV[0]).read)
text_config = JuniperHash.build_config_from_hash(hash_config)
JuniperHash.get_hash(text_config) == hash_config
puts hash_config
end
@nanotechz9l
Copy link
Author

simple ruby script to parse juniper router configuration into nested hash

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment