It's still not perfect as it still involves some waiting and may or may not get false positives. I haven't tested this with mc, but it worked with python3 and zsh (As far I could test it, see section "Tests"). I moved the script and some docmentation to a github repository. Proof of Concept with Process Status/Strace You could just look for newlines ( \n) and if you know how many lines the output should have, you can count them and 'know' that it has finished running and is waiting for input again. Having the Server running as a Child Process in Node enables you to interact with the stdin and stdout of the process in Node. This method is used in the proof-of-concept script below, in combination with the stack trace. Maybe someone knows a more precise way to do this?Ī good indicator might be to check if the process is running or sleeping. It is just looking for an open parenthesis now. There may be few other possibilities, which is why I didn't limit the RegEx in the script below to just that. While testing this, I encountered read(10, ( zsh) and select(1,, NULL, NULL, NULL ( python3 cli interpreter). It could be combined with the line-counting proposal below for more accuracy. It may also have to involve some guessing based on how long it is stuck and at which file descriptor. ![]() ![]() That may be a bit tricky because it may be temporarily stuck at at another read before the desired one. Also see: How do I tell if a command is running or waiting for user input?. A way to do that would be running a stack trace and looking for that. To make it work properly, you'd have to detect at which point the program you are feeding commands is stuck at a relevant IO Operation. You can use a fifo to get the output of a command in screen, but I doubt that the 'minecraft shell' will support that. I don't think this is possible in screen.
0 Comments
Leave a Reply. |