Use stdin from CLI launch to send console commands

Wed Sep 01, 2021 8:31 pm

Would it be possible to redirect stdin from the CLI into the in-game console. This would be similar to how, say, Zandronum-server works. All the output from GZDoom console currently gets outputted to the CLI so it would still be consistent, and this would allow wrappers for GZDoom to issue commands into a running game.

Re: Use stdin from CLI launch to send console commands

Thu Sep 02, 2021 12:09 am

If you need interprocess communication with GZDoom then it should be cross-platform and more explicit than reading from stdin.
Most of users run Windows, but GZDoom doesn’t output anything to command prompt window. So, consistency is a wrong premise here as well.

In general, IPC can be useful for various reasons. Although, it should work on three main platforms identically. That's the main problem with its implementation.

Re: Use stdin from CLI launch to send console commands

Thu Sep 02, 2021 12:20 am

In Windows, console output is controlled by a command line option, but the entire thing doesn't actually write to stdout but directly to Windows's console. And that console API is broken beyond repair for Unicode output anyway. Its main reason for existence is being able to see console output in a debug session otherwise I would have removed that code already.

Re: Use stdin from CLI launch to send console commands

Thu Sep 02, 2021 2:22 am

_mental_ wrote:If you need interprocess communication with GZDoom then it should be cross-platform and more explicit than reading from stdin.


Definitely wouldn't mind this, but I'm unfamiliar with what options would be available to do that with GZDoom. For my own project I'm looking to tell a live session to execute scripts just like I would with the console in-game, only triggered from outside of the game. It's not robust and wouldn't allow you a lot of flexibility, but since the process can already output to the terminal with stdout I thought reading from stdin would be simpler and more likely to be implemented.

Most of users run Windows, but GZDoom doesn’t output anything to command prompt window. So, consistency is a wrong premise here as well.


That is true, my apologies, I had wrongfully assumed that Windows would output the same as it does on MacOS and Linux if you launched it directly.


If this is not a feature that can be implemented, would it be feasible to use ACS or ZScript to dump console output to a file or read input from another file? Most of my experience dealing with ACS is for control through the console since my previous project used Zandronum Server which allows me to hook it this way. If so I can go looking for it but I'm not really sure if that's possible as an alternative.

Thank you for your time on this.

Re: Use stdin from CLI launch to send console commands

Thu Sep 02, 2021 2:39 am

Writing files from any kind of scripts is considered harmful. Reading files that changes externally is possible via ZScript, although it could be a bad idea depending on how it affects the game.