Questions tagged [python-textfsm]

a template-based state machine for parsing semi-formatted text in Python that is often used to analyze the output of CLI driven devices, such as network routers and switches, but it can be used for any textual output. This tag should not be confused with [fsm].

TextFSM is a template-based finite state machine for parsing semi-formatted text in Python developed at Google Inc.

This tag should be only used for questions specific to TextFSM and not for general or questions that work the same outside of the context of TextFSM. Should not be confused with finite state machine questions as well.

The purpose of TextFSM is to simplify the extraction of semi-structured data out of traditional network devices, such as network routers and switches, but it can be used for any (CLI-driven) textual output.

Basically, an extraction and transformation template, consisting of variables and rules with regular expressions, is applied to text input, e.g. a log file, to produce the desired result.

Further Information:

59 questions
5
votes
1 answer

how to parse text using TextFSM with option (like or condiiton)

I need to parse out 'show env all' from switch/router, but there's have different text structure. Switch A : FAN is OK SYSTEM TEMPERATURE is OK System Temperature Value: 38 Degree Celsius System Temperature State: GREEN Yellow Threshold : 58 Degree…
Nedy Suprianto
  • 201
  • 1
  • 6
  • 14
5
votes
3 answers

How to parse text over multiple lines with textfsm?

I understood that TextFSM is a good way to parse text files, however, I see that it can parse data over single lines, my question is how to parse text spread over multiple lines. CUSIP No. 123456 13G …
Trinadh Gupta
  • 306
  • 5
  • 18
4
votes
0 answers

I want to keep default values in regular expressions if pattern does not match

I want to keep default values in regular expressions if the pattern does not match Value LINK_GROUP_NAME (\S+) Start ^ link-group ${LINK_GROUP_NAME} Above is my python textfsm template. Here if my regular expression doesn't match then I want to…
Dhananjaya D N
  • 347
  • 2
  • 11
3
votes
2 answers

How to extract comma separated substrings from a string?

Need to parse the algorithms separated by comma in group. SSH Enabled - version 2.0 Authentication methods:publickey,keyboard-interactive,password Encryption Algorithms:aes128-ctr,aes192-ctr,aes256-ctr,aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc MAC…
2
votes
1 answer

Find a value in a structured file with Ansible

Here I have a small question about how to find a value in a structured file using Ansible. I've seen lineinfile but I'm not pretty sure that it will be helpful. If we assume that my file looks like this (in fact it's way way longer but for evident…
a-maxime
  • 35
  • 3
2
votes
1 answer

Is there a way to Continue with the same line in State changes in TextFSM?

I know that I can't combine state transitions with a continue statement. I'm trying to parse network configuration with ansible where the only clear end of row its the beginning of the next one. For example I want to parse configs like follows: line…
2
votes
1 answer

Is there a way to record multiple lines at once with TextFSM?

I want to parse a Checkpoint Firewall cphaprob -a if executed via Netmiko using TextFSM. The final generated list is not well formatted. I already tried a lot of TextFSM combination of commands but maybe I just fail to understand how it properly…
Gane D. Geoffrey
  • 165
  • 1
  • 4
  • 10
2
votes
0 answers

Calling 3rd Party Module python functions from ironpython in C#

I have to call textfsm python module functions from c#. I am using Ironpython for this. Current code ScriptEngine engine = Python.CreateEngine(); var paths = engine.GetSearchPaths(); string dir2 = @"C:\Program…
cipher94
  • 203
  • 1
  • 12
2
votes
2 answers

AttributeError: 'str' object has no attribute 'seek' using textfsm module (regex)

I'm trying to use the textfsm module which uses regex, and importing data into a text file. Below is my code: from netmiko import ConnectHandler from textfsm import * cisco_device = { 'device_type' : 'cisco_ios', 'ip' : 'x.x.x.x',…
Goldy Tomy
  • 85
  • 1
  • 9
1
vote
1 answer

multiple lines into a list of variables

I'm having difficulty with a show license summary template for cisco. It's close, but not quite, and this is my first template so any help is appreciated. The CLI output is Smart Licensing is ENABLED Registration: Status: REGISTERED Smart…
ntwrkguy
  • 23
  • 3
1
vote
1 answer

TextFSm to get convert following text

x y z a b c ------ ----------- ------------------ ------------ --------------- ------------ 4000 4000 No ID Hun0/0/12 1.1.1.1 0 4001 …
bell
  • 11
  • 2
1
vote
1 answer

textFSM Collect values into list using the same Value variable

I'm new to textFSM. Trying to use the same value to find and save multiple instances of a value matches across multiple lines of input text. I have tried a number of different constructs but none provides the desired output. Input set= 1. text1 …
user3490280
  • 21
  • 1
  • 5
1
vote
1 answer

Question with Netmiko and TextFSM against cisco IOSXE

Trying to do a check against Cisco IOSXE to see if any ports are still configured in the default VLAN. Output = net_connect.send_command ('show int status', use_textfsm=true) for i in output: if i["vlan"] == "1": print ('Not compliant') …
Jimmy
  • 31
  • 1
  • 7
1
vote
1 answer

Python # Pyinstaller build problem on using Text Fsm

I made a simple program by using Python to access CISCO devices. I am using the Netmiko Textfsm method for this. When I build an .exe using pyinstaller it works fine. However, if I copy the .exe to another PC, it shows an error: Directory…
1
vote
1 answer

Using textFSM to parse multiple show commands

I'm trying to use textFSM to compile some Juniper "show" command outputs and get specific fields from them and finally printing collected info in one run. This is my code: import textfsm import getpass from netmiko import ConnectHandler from…
1
2 3 4