Thanks! that helps.. i also found another solution that is a bit simpler...
i do something like this
def findDHCP(filename):
f = open(filename, "r")
text = f.read()
word = re.findall("(.*)Offer",text)
splitter = re.compile('[\s]+')
for n in word:
temp = n;
s = splitter.split(temp)
print ("The DHCP Server IP is :"+s[3])
print ("The IP allocated to me is :"+s[4])
but the problem isthis reads only till the end of that particular line.. now i want to read a line that is a constant number of lines below what i read through the above code. But the problem is the 2nd line i want to read doesnt have any siignificant indexes or anything to look for.... Is there someway I can do this?
Basically i want to read a block of text spread through a few lines between a KNOWN start point and END point (i've
bolded the 2 points) and the Src Port and the Dest Port (in red) are what i want to extract
No. Time Source Destination Protocol Info
140 3.050240 137.132.69.169 172.19.134.182 FTP Response: 150 Opening BINARY mode data connection for /pub/ubuntu/dists/dapper-security/Contents-i386.gz (3376313 bytes).
Frame 140 (179 bytes on wire, 179 bytes captured)
Ethernet II, Src: Ditech_55:38:00 (00:d0:02:55:38:00), Dst: Usi_ac:fe:1e (00:16:41:ac:fe:1e)
Internet Protocol, Src: 137.132.69.169 (137.132.69.169), Dst: 172.19.134.182 (172.19.134.182)
Transmission Control Protocol, Src Port: ftp (21), Dst Port: 59785 (59785), Seq: 85, Ack: 178, Len: 113
File Transfer Protocol (FTP)
No. Time Source Destination Protocol Info
141 3.051247 137.132.69.169 172.19.134.182 FTP-DATA FTP Data: 1368 bytes
Frame 141 (1434 bytes on wire, 1434 bytes captured)
Ethernet II, Src: Ditech_55:38:00 (00:d0:02:55:38:00), Dst: Usi_ac:fe:1e (00:16:41:ac:fe:1e)
Internet Protocol, Src: 137.132.69.169 (137.132.69.169), Dst: 172.19.134.182 (172.19.134.182)
Transmission Control Protocol, Src Port: 50003 (50003), Dst Port: 48115 (48115), Seq: 1, Ack: 1, Len: 1368
FTP Data