我有一个由moxa开关show running-config输出的cli。接口节可能有名称字符串,也可能没有。
interface ethernet 1/3
shutdown
name Unused
speed-duplex Auto
no flowcontrol
media cable-mode auto
no gmrp
switchport access vlan 1
rate-limit port-disable ingress rate none
no ptp
!
interface ethernet 1/8
shutdown
speed-duplex Auto
no flowcontrol
media cable-mode auto
no gmrp
switchport access vlan 1
rate-limit port-disable ingress rate none
no ptp这是我的用于解析的FSM模板
Value port (\d\/\d)
Value state (shutdown|no shutdown)
Value desc (\S+)
Start
^interface ethernet ${port} -> Continue.Record
^.${state}
^.name.${desc}但是通过这种方式,接口名称的输出被下移了一行。如何修复此模板?
输出示例
port state desc
------ ----------- ----------------
1/1
1/2 no shutdown Cisco_2960_OTPSS
1/3 no shutdown Mirror
1/8 shutdown Unused
1/9 shutdown
no shutdown Proverka发布于 2021-04-17 19:50:04
链路TextFSM usage显示的示例与您在描述不完整的路由条目时遇到的问题非常相似:
当下一个完整的路由条目出现时,确实应该写入
...incomplete路由条目,但同时应该将它们写入适当的路由。应执行以下操作:一旦满足完整路由条目,则应写下之前的值,然后继续处理相同的完整路由条目以获取其信息。
在您的上下文中:
^interface ethernet -> Continue.Record在这里,
Record动作告诉你写下变量的当前值。由于此规则中没有变量,因此将写入先前值中的内容。Continue操作指示继续处理当前行,就好像没有匹配项一样。
Start
^interface ethernet -> Continue.Record
^interface ethernet ${port}
^.${state}
^.name.${desc}port state desc
------ -------- ------
1/3 shutdown Unused
1/8 shutdownhttps://stackoverflow.com/questions/67115016
复制相似问题