Hami
Hami

Reputation: 714

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 idea possible?

this is how server window looks like, just imagine that the last line says: "Your server is out of date. Please update and restart."

Upvotes: 0

Views: 381

Answers (1)

m0skit0
m0skit0

Reputation: 25873

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

Upvotes: 1

Related Questions