Parse command line output using textfsm

Ferdinand Sousa ferdinandsousa at gmail.com
Thu Jun 21 11:38:14 EDT 2012


Hi List,

I am using python to run command line utilities on Linux machine.
I came across textfsm and feel that it fits my requirements.

Here is the structure of the output from the 2 utilities

Command 1:

Id Address    Port Location State  Tenant count Max tenants Description
-- ---------- ---- -------- ------ ------------ ----------- ------------
1  10.0.32.20 8443 -        ACTIVE    7            12       -
2  10.0.32.21 8443 -        ACTIVE    7            12       -
3  10.0.32.22 8443 -        ACTIVE    7            12       -

Command 2:

1    2012-04-04 19:54 00DD0000000q3di GOLD    Company 1       CA360
ACTIVE      Yes       https://10.0.32.26:7000 8         50
17  2012-04-09 23:01 00Dd0000000efRF SILVER  Company 2       CA360
ACTIVE      Yes       https://10.0.32.20:7014 1         440
27  2012-04-10 03:42 00Dd0000000efdS TRIAL     Company 3       CA360
ACTIVE      Yes       https://10.0.32.23:7021 4         10
32  2012-04-11 11:24 00Dd0000000eiGb TRIAL     Company 4      CA360
INACTIVE   Yes       https://10.0.32.21:7000 2         25

I found this link documenting how to parse tabular data:
http://code.google.com/p/textfsm/wiki/TextFSMCodeLab#Parsing_tabular_data
My question is, what is the syntax of the pattern matching used. Is it the
same as python regexp?
Any other documentation/examples available for this library?

I'm also open to suggestions of using other libraries.
Basically, I would like this to be semantically as close as possible to
working with data extracted from a database.

Thanks and regards,
Ferdi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120621/b8dd30c4/attachment.html>


More information about the Python-list mailing list