Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

Query: Rule Based Command Line Response Parser

Thread view: 
mehta.rulz@gmail.com - 05 Dec 2007 04:42 GMT
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
Roedy Green - 06 Dec 2007 10:13 GMT
On Tue, 4 Dec 2007 20:42:52 -0800 (PST), "mehta.rulz@gmail.com"
<mehta.rulz@gmail.com> wrote, quoted or indirectly quoted someone who
said :

>I was looking for a rule based parser as i feel it will avoid normal
>hardcoding that most of parsers have

Is your complaint you must run the parser, then the compiler before
you can parse?  You can arrange this with on-the-fly techniques.

See http://mindprod.com/jgloss/onthefly.html
http://mindprod.com/jgloss/parser.html
Signature

Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.