I need to write a simple script which will display in real time the contents of /proc/net/xt_recent/PORTSCAN
. This file is constantly changing and I want to read it in an infinite loop and display as accurately as possible the "instantaneous" state. A sample contents of my file looks like this:
src=123.45.67.89 ttl: 64 last_seen: 4298265432 oldest_pkt: 1 4298265432
src=132.45.67.89 ttl: 64 last_seen: 4298265432 oldest_pkt: 1 4298265432
src=231.45.67.89 ttl: 64 last_seen: 4298265432 oldest_pkt: 1 4298265432
Can I use the standard
line = f.readline()
Or is there some better way in to read this file. My concern is to avoid any possible inconsistencies, while reading a file which is changing (lines being added, removed, etc)