The code is not entering the second for loop. I am not modifying the file descriptor anywhere. Why is that happening?
import os
import re
path = '/home/ajay/Desktop/practice/ajay.txt'
os.system('ifconfig>>path')
fd = open(path,'r+')
interfaces = []
tx_packets = []
for line in fd:
if(re.search(r'(\w+)\s+\Link',line)):
inter = re.match(r'(\w+)\s+\Link',line)
interface = inter.group(1)
interfaces.append(interface)
for lines in fd:
if(re.search(r'\s+TX packets:(\d+)',lines)):
tx_packs = re.match(r'\s+TX packets:(\d+)',lines)
tx_pack = tx_packs.group(1)
tx_packets.append(tx_pack)
print interfaces
print tx_packets