M
mehta.rulz
Hi
I am looking for some open source Rule Based Command Line Response
Parser.
By rule based i mean i wish to provide an input file (which will
contain parsing rules for a particular command).
Example: For command 'route' following is response.
[anuj@anuj ~]$ /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref
Use Iface
172.31.44.0 * 255.255.255.0 U 0
0 0 eth0
169.254.0.0 * 255.255.0.0 U 0
0 0 eth0
default 172.31.44.1 0.0.0.0 UG 0
0 0 eth0
Now suppose i want to save above data in a HashMap/Table (rowwise or
column wise). So for that i may create an input file which will have
rules in say XML
1) Fields are in order "Destination", "Gateway" etc
2) There may be some empty lines which needs to be skipped eg. Skip
first 3 lines.
3) Look out for a particular string and then retrieve the value which
follows the string.
Eg. cpuid level : 2
Here i may look for "cpuid level" and then store its value "2" in a
field in HashTable.
I was looking for a rule based parser as i feel it will avoid normal
hardcoding that most of parsers have. Since it works according to
rules specified it can be used for parsing of response of any type of
CLI devices.
Do let me know anyone has idea related to it.
Thanks,
Anuj
I am looking for some open source Rule Based Command Line Response
Parser.
By rule based i mean i wish to provide an input file (which will
contain parsing rules for a particular command).
Example: For command 'route' following is response.
[anuj@anuj ~]$ /sbin/route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref
Use Iface
172.31.44.0 * 255.255.255.0 U 0
0 0 eth0
169.254.0.0 * 255.255.0.0 U 0
0 0 eth0
default 172.31.44.1 0.0.0.0 UG 0
0 0 eth0
Now suppose i want to save above data in a HashMap/Table (rowwise or
column wise). So for that i may create an input file which will have
rules in say XML
1) Fields are in order "Destination", "Gateway" etc
2) There may be some empty lines which needs to be skipped eg. Skip
first 3 lines.
3) Look out for a particular string and then retrieve the value which
follows the string.
Eg. cpuid level : 2
Here i may look for "cpuid level" and then store its value "2" in a
field in HashTable.
I was looking for a rule based parser as i feel it will avoid normal
hardcoding that most of parsers have. Since it works according to
rules specified it can be used for parsing of response of any type of
CLI devices.
Do let me know anyone has idea related to it.
Thanks,
Anuj