I have this game I run with shell script. When the game is running through terminal, it actively prints informations like "Connected to Server" or "Disconnected" and so on.
const app = Application.currentApplication()
app.includeStandardAdditions = true
const terminalOutput = app.doShellScript('pathToGame');
console.log(terminalOutput);
This code only prints out when the application stops/quits. Just the last statement is printed. I was trying to find a way to get every statement printed. Whether its in a log file or as a return value everything it prints something while the process is running, without having to stop/quit it.
01:21:22: Application Running
01:21:23: Request connection to "ip address"
01:21:24: Connected to server "ip address"
01:45:01: Disconnected from server "ip address"
//Here my script would detect and try to log in again
For example: I open the game. The game prints "Application Running", now with that value, I know the game is open and I can tell my script to log in. Then, if somehow the game prints "Disconnected from server" my app will detect that stdout and will fall into a function where it is going to try to log in again.
Is getting stdout while the app is still running possible?