I'm running a program from the command line. This program prints out some of my CPU's statistics (link to program if anyone's interested: https://github.com/opcm/pcm). The program doesn't exit. It'll print updated stats periodically in the same terminal.
I'm trying to use these stats that the program is retrieving in another program that I'm writing myself. The program I'm writing is just supposed to graph some of these CPU statistics vs. time in real time in python.
I'm not sure how to retrieve and use the stats being printed to the console in my program in real time. I know I can direct output to a text file instead of to the console by typing ./program.x > output.txt
.
My first thought is to push the outputted statistics to a text file, and simultaneously be reading from that text file in my program. But this feels like a brute force method, and I'm not sure it'll work.
Does anyone know how I can use the real-time output from one program in another program?