开发者

Read program output C++

I have a TF2 server and if TF2 gets updated while I'm away, server will output:

Your server is out of date. Please update and restart.

How could I observer/read the output with C++?

The idea is:

         1. if (output == "Your server is out of date. Please update and restart.")
         2. kill the application
         3. run update.bat
         4. start observing again

Is my i开发者_StackOverflowdea possible?

Read program output C++


That's basically a watchdog.

A solution can be done using piping:

Pipe your server output to standard input from your C++ application (reading it with cin will do). For example, if your TF2 server is tf2.exe and your C++ app is cpp.exe:

tf2.exe | cpp.exe

You will need to execute this command again everytime you're restarting the server (which involves exiting the C++ app after doing so since it will be re-run by the command).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜