Jan-21-2018, 07:24 PM
Greetings all,
I have a configuration file and after much reviewing I found there is some structure to it, but not sure how to reach in and get the elements out of it. So the file can be quite large, but I am trying to parse through some Firewall configurations and what I found is that for every line that starts with 'config' there is a corresponding line that starts with 'end' which make up the block of code. But inside each of these there could be many other config end pairs. For Clarity I indented the text below, but all of these are at the beginning of the line so ^config and ^end. There are other config and end pairs in the code, but they are tab indented so they will not matter.
Is there a module or something that would match brackets or something? Then I could start the script and change every line that startswith 'config' to {config and evey line that startswith 'end' to end} and then be able to parse through it. So at the end of the day:
would be a set of text I would work with etc....
config system global
information
end
I have a configuration file and after much reviewing I found there is some structure to it, but not sure how to reach in and get the elements out of it. So the file can be quite large, but I am trying to parse through some Firewall configurations and what I found is that for every line that starts with 'config' there is a corresponding line that starts with 'end' which make up the block of code. But inside each of these there could be many other config end pairs. For Clarity I indented the text below, but all of these are at the beginning of the line so ^config and ^end. There are other config and end pairs in the code, but they are tab indented so they will not matter.
Is there a module or something that would match brackets or something? Then I could start the script and change every line that startswith 'config' to {config and evey line that startswith 'end' to end} and then be able to parse through it. So at the end of the day:
would be a set of text I would work with etc....
config system global
information
end
config global
config system global
information
end
config system accprofile
information
end
config system np6
information
end
config system interface
information
end
config system custom-language
information
end
config system admin
information
end
end <<<<< ends the config global from above
config vdom
config system settings
information
end
config system replacemsg-group
information
end
config firewall address
information
end
config firewall multicast-address
information
end
end <<< ends the config vdom from above
config vdom
config system settings
information
end
config system replacemsg-group
information
end
config firewall address
information
end
config firewall multicast-address
information
end
end <<< ends the config vdom from above
