Python Forum
save the output from scapy to txt file
Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
save the output from scapy to txt file
#5
(Oct-09-2017, 09:30 AM)Larz60+ Wrote: you can redirect stdout:
if __name__ == "__main__":
    import sys
    sys.stdout = open('textout.txt', 'w')
    ... rest of your code here ...
    sys.stdout.close()

so it should be like this?
if __name__ == "__main__":
	import sys
	sys.stdout = open('textout.txt', 'w')
    if lena == 1:
        for network, netmask, _, interface, address in scapy.config.conf.route.routes:
            # skip loopback network and default gw
            if network == 0 or interface == 'lo' or address == '127.0.0.1' or address == '0.0.0.0':
                continue
                
            if netmask <= 0 or netmask == 0xFFFFFFFF:
                continue
        
        net = to_CIDR_notation(network, netmask)
        if interface != scapy.config.conf.iface:
            # see http://trac.secdev.org/scapy/ticket/537
            logger.warn("skipping %s because scapy currently doesn't support arping on non-primary network interfaces", net)
            #continue
        if net:
            scan_and_print_neighbors(net, interface)
            repr(network)
            
    sys.stdout.close()
    elif lena == 3 :
        print("Bye Bye  ")

@Larz60+
thank u very much it's working <3
Reply


Messages In This Thread
RE: save the output from scapy to txt file - by evilcode1 - Oct-09-2017, 09:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Open/save file on Android frohr 0 437 Jan-24-2024, 06:28 PM
Last Post: frohr
  how to save to multiple locations during save cubangt 1 648 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  save values permanently in python (perhaps not in a text file)? flash77 8 1,430 Jul-07-2023, 05:44 PM
Last Post: flash77
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,240 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 3,427 Feb-20-2023, 07:19 PM
Last Post: avd88
  Save multiple Parts of Bytearray to File ? lastyle 1 1,028 Dec-10-2022, 08:09 AM
Last Post: Gribouillis
  Permission issue when using scapy jao 3 10,544 Feb-05-2022, 06:14 PM
Last Post: snippsat
  Deploy Python to Cloud and save output to Google Drive chandrabr80 2 1,688 Jan-25-2022, 06:56 AM
Last Post: ndc85430
Sad Want to Save Print output in csv file Rasedul 5 11,480 Jan-11-2022, 07:04 PM
Last Post: snippsat
  How to save Matplot chart to temp file? Morkus 2 4,688 Jun-12-2021, 10:52 AM
Last Post: Morkus

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020