I am an intermediate Python programmer. In my experiment, I use Linux command that outputs some results something like this:
OFPST_TABLE reply (xid=0x2):
table 0 ("classifier"):
active=1, lookup=41, matched=4
max_entries=1000000
matching:
in_port: exact match or wildcard
eth_src: exact match or wildcard
eth_dst: exact match or wildcard
eth_type: exact match or wildcard
vlan_vid: exact match or wildcard
vlan_pcp: exact match or wildcard
ip_src: exact match or wildcard
ip_dst: exact match or wildcard
nw_proto: exact match or wildcard
nw_tos: exact match or wildcard
tcp_src: exact match or wildcard
tcp_dst: exact match or wildcard
My goal is to collect the value of parameter active= which is variable from time to time (In this case it is just 1). I use the following slicing but it does not work:
string = sw.cmd('ovs-ofctl dump-tables ' + sw.name) # trigger the sh command
count = count + int(string[string.rfind("=") + 1:])
I think I am using slicing wrong here but I tried many ways but I still get nothing. Can someone help me to extract the value of active= parameter from this string?
Thank you very much :)