[antlr-interest] Query: Rule Based Command Line Response Parsing using ANTLR
Gavin Lambert
antlr at mirality.co.nz
Wed Jan 16 11:15:42 PST 2008
At 22:51 16/01/2008, Anuj Mehta wrote:
>Can we use ANTLR for parsing "response" from a command (CLI)?
>
>Example: For command 'route' following is response.
>
>[anuj at 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
You could, but it's probably just as easy (if not easier) to parse
this as simple tab-separated data.
Of course, since this command is not required to generate stable
or machine-parsable output, a better option would be to track down
the APIs you need to call to obtain the equivalent information,
rather than trying to parse the output of another command.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/antlr-interest/attachments/20080117/b910fe68/attachment.html
More information about the antlr-interest
mailing list