Query: Rule Based Command Line Response Parser
- From: "mehta.rulz@xxxxxxxxx" <mehta.rulz@xxxxxxxxx>
- Date: Tue, 4 Dec 2007 20:42:52 -0800 (PST)
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
.
- Follow-Ups:
- Re: Query: Rule Based Command Line Response Parser
- From: Roedy Green
- Re: Query: Rule Based Command Line Response Parser
- Prev by Date: Re: Newbie wants to self-taught java
- Next by Date: Re: Newbie wants to self-taught java
- Previous by thread: OT: Git versus Subversion
- Next by thread: Re: Query: Rule Based Command Line Response Parser
- Index(es):
Relevant Pages
|