Page 1 of 1

How to get STDOUT and STDIN of a server?

PostPosted: Sat Jul 20, 2019 08:23
by texmex
I want to be able to pipe the STDOUT of the server to another service while at the same time be able to send commands into it through STDIN.

I know of the --terminal server option which grants me the use of STDIN but I don't get STDOUT when enabled.

How do I pipe output to STDOUT in terminal server mode?
OR
How do I get STDIN and STDOUT in any other way? (I really don't care how hacky it would be, be it through mods or terminal voodoo)

Re: How to get STDOUT and STDIN of a server?

PostPosted: Sat Jul 20, 2019 09:25
by Chiantos
Deleted message

Re: How to get STDOUT and STDIN of a server?

PostPosted: Sat Jul 20, 2019 11:41
by orwell
Hm, possibly get Stdout the normal way, and then create a named pipe (mkfifo), open that from Lua and parse commands in there, like
Script (not sure whether this works)
Code: Select all
mkfifo path/to/world/in.fifo
minetestserver --worldname x | process-for-stdout &
tee in.fifo

As mod, find the external-cmd mod and modify it so that it opens and reads from in.fifo
Code: Select all
local infifo = io.open(worldpath.."in.fifo")
... in a globalstep or so...
  local cmd = infifo:read("*l")
  ... handle cmd ...
end


Edit: This one viewtopic.php?id=3924
Edit2: Hm, this would block the lua thread when there are no new data. You would need nonblocking IO... Maybe just use external_cmd as-is

Re: How to get STDOUT and STDIN of a server?

PostPosted: Sat Jul 20, 2019 12:46
by texmex
Excellent, orwell, I got to try this. I’m a terminal novice so this is of great help.

This should really be an engine feature, right? Pretty ”standard” as it were. ;)