I using scapy with python in ubuntu. I would like to ask if anyone would know how to code the example:
let say I have two text files which are writing while the script is running then I would like to check the file is exceed example 500bytes, if does then it will store whatever in the file and create a new text file to write. (output1.txt, output2.txt,etc..)
Would be appreciated if any expertise will help. Thanks
part of my code is:
file = open("output.txt","w")
def example(p):
if p.haslayer(Dot11Beacon):
if p.addr2 not in uniqueAP:
file.writelines(p.addr2 + "\n")
so while the script is running in the terminal, it will write it into the file called output.txt but i would want to improve the script to check file size of the text file and if exceed it would stop writing in the current and create a new output2.txt for example and continue.