Python Forum
starting and reading from a process
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
starting and reading from a process
#1
i want to be able to start a process (perhaps using Popen()) and read its output. i need for this reading to be fully unbuffered or buffered by lines so that i get all data as soon as that process does the system call to output it, collecting data only up to the end of line only when doing it line buffered. i also want to know whether the data came from the process writing to stdout or writing to stderr (it is unknown in advance which stream the next data will be written to) and finally, i need to know when each stream ends with some genuine end of file condition that is fully distinguished from any and all possible data.

the script doing all this will be modifying the data or doing something with the data it reads. examples (plural) of things it might do include putting a timestamp on each line, or putting the letters "o" or "e" at the front of each line, or counting the number of times the word "apple" appears in the stdout stream while also counting the number of times the word "peach" appears in the stderr stream. future examples are unknown. no particular example should be focused on if you are wanting to help on this.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading data from excel file –> process it >>then write to another excel output file Jennifer_Jone 0 1,092 Mar-14-2023, 07:59 PM
Last Post: Jennifer_Jone
  How to sharing object between multiple process from main process using Pipe Subrata 1 3,661 Sep-03-2019, 09:49 PM
Last Post: woooee
  starting a process every 10 seconds Skaperen 7 15,195 Dec-31-2017, 03:47 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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