tags:

views:

50

answers:

3

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
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
A: 

Check out popen http://linux.die.net/man/3/popen This should do what you need.

Vlad