I have a program which continually receives data from an external source and prints it to the terminal. I am now trying to create a GUI to display the received data. Is there some way for me to do this without changing the pre-existing code (that is the old code calls a print statement and what is printed gets displayed in the GUI)?
+2
A:
Pipe the output of the command-line program into a GUI program that displays whatever it receives on its stdin.
Jim Lewis
2010-06-04 19:18:42
A:
If what the old code prints out is reasonably structured, then you have a chance of having the gui parse it. You'd do this by piping the output from the old code and having the gui read from stdin (or whichever fd you set it up as; if it's reasonable to do so, you might have the gui fork
and exec
the old code).
crazyscot
2010-06-04 19:18:55
A:
Check out popen http://linux.die.net/man/3/popen This should do what you need.
Vlad
2010-06-04 19:19:20