I got a line like this :
20:28:26.684597 24:d5:6e:76:9s:10 (oui Unknown) > 45:83:r4:7u:9s:i2 (oui Unknown), ethertype 802.1Q (0x8100), length 78: vlan 64, p 0, ethertype IPv4, (tos 0x48, ttl 34, id 5643, offset 0, flags [none], proto TCP (6), length 60) 192.168.45.28.56982 > 172.68.54.28.webcache: Flags [S], cksum 0xg654 (correct), seq 576485934, win 65535, options [mss 1460,sackOK,TS val 2544789 ecr 0,wscale 0,eol], length 0
In this line I need to find ID value from "id 5643" and another value (56982) from 192.168.45.28.56982
.
In these "id" will be constant and 192.168.45.28
is constant.
I have written a script like this, please suggest a way to shorten the code as in my script multiple steps are involved :
file = open('test.txt')
fi = file.readlines()
for line in fi:
test = (line.split(","))
for word2 in test:
if "id" in word2:
find2 = word2.split(" ")[-1]
print("************", find2)
for word in test:
if "192.168.45.28" in word:
find = word.split(".")
print(find)
for word1 in find:
if ">" in word1:
find1 = word1.split(">")[0]
print(find1)
#