I am doing the live packet capture through Tcpdump and saving the result in a simple text file. What I'm trying to achieve is to look for two or more strings in the packet capture text file. Because the output of the packet capture would never end (until we stop), I can not think of the control flow of the program I want to write using Python.
A solution to this problem may be to add a certain unique keyword after searching for a specific number of lines and then continue with that keyword the next time
Next equal to the next set of lines again. This will continue until we stop the packet capture data in a flat file.
What I want –
If string1 is found:
Print "string1 found"
If string2 is found:
Print "string2 found"