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
#11
(Oct-10-2017, 11:39 AM)Larz60+ Wrote: The intent is to overwrite sys.stdout -- This will redirect text to the file
remove the close

also make sure you imported sys

i need to redirect text to the file :)
the script is doing this scan network range and then save them to .txt file on linux machine and then run external python script for (eternal blues vulnerability scanner) by using this command detect_doublepulsar_smb.py --file last.txt

when i remove the close() i got an empty file and when i leave the close() i got this error
Quote:Traceback (most recent call last):
File "test.py", line 113, in <module>
lena = int(raw_input("Enter Number : "))
ValueError: I/O operation on closed file
Reply
#12
What this does is redirect all stdout text to the file.
The error should be going to stderr, but since you see it in the file, that's not happening.
If you're using interactive text, as you are, the redirect cannot be used because you will not see your input statements.
The error must be going to stdout, and not stderr.

normally, before reassignment you can save stdout in a variable before reassignment, and rather than close
restore to value in variable. See: https://python-forum.io/Thread-class-tha...io-to-file

But i didn't see the interactive (input statements), so you cannot use this method unless localized.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Open/save file on Android frohr 0 332 Jan-24-2024, 06:28 PM
Last Post: frohr
  how to save to multiple locations during save cubangt 1 554 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  save values permanently in python (perhaps not in a text file)? flash77 8 1,234 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,107 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  Save and Close Excel File avd88 0 3,059 Feb-20-2023, 07:19 PM
Last Post: avd88
  Save multiple Parts of Bytearray to File ? lastyle 1 955 Dec-10-2022, 08:09 AM
Last Post: Gribouillis
  Permission issue when using scapy jao 3 9,809 Feb-05-2022, 06:14 PM
Last Post: snippsat
  Deploy Python to Cloud and save output to Google Drive chandrabr80 2 1,579 Jan-25-2022, 06:56 AM
Last Post: ndc85430
Sad Want to Save Print output in csv file Rasedul 5 10,956 Jan-11-2022, 07:04 PM
Last Post: snippsat
  How to save Matplot chart to temp file? Morkus 2 4,530 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