Query: Rule Based Command Line Response Parser

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top