I have written a Python code where I call below Scappy API:
sendp(packet, iface=adapter_name) The code works fine but issue is that it prints below line on console where the program is executing as many times the above command is called:
Sent 1 packets. . I need to suppress the console output so I tried:
old_stdout = sys.stdout sys.stdout = log_file_name But then I get exception:
sendp(packet, iface=adapter_name) File "C:\Python36\lib\site-packages\scapy\sendrecv.py", line 315, in sendp verbose=verbose, realtime=realtime, return_packets=return_packets) File "C:\Python36\lib\site-packages\scapy\sendrecv.py", line 289, in __gen_send print("\nSent %i packets." % n) AttributeError: 'str' object has no attribute 'write' How can achieve the objective?
verbose=0on your send command to remove the logs... instead of doing a redirection :p