简体   繁体   中英

How to exchange data between programs using the terminal?

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)?

将命令行程序的输出通过管道传输到GUI程序,以显示其在stdin上收到的内容。

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).

请访问popen http://linux.die.net/man/3/popen,这应该可以满足您的需求。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM