How to get STDOUT and STDIN of a server?

Post Reply
User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

How to get STDOUT and STDIN of a server?

by texmex » Post

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)

Chiantos
Member
Posts: 377
Joined: Sun Jan 15, 2017 09:04

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

by Chiantos » Post

Deleted message
Last edited by Chiantos on Mon Sep 30, 2019 05:35, edited 1 time in total.

User avatar
orwell
Member
Posts: 958
Joined: Wed Jun 24, 2015 18:45
GitHub: orwell96
IRC: orwell96_mt
In-game: orwell
Location: Raxacoricofallapatorius

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

by orwell » Post

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
Lua is great!
List of my mods
I like singing. I like dancing. I like ... niyummm...

User avatar
texmex
Member
Posts: 1753
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

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

by texmex » Post

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

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 9 guests