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)
How to get STDOUT and STDIN of a server?
- 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?
Deleted message
Last edited by Chiantos on Mon Sep 30, 2019 05:35, edited 1 time in total.
- 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?
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)
As mod, find the external-cmd mod and modify it so that it opens and reads from in.fifo
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
Script (not sure whether this works)
Code: Select all
mkfifo path/to/world/in.fifo
minetestserver --worldname x | process-for-stdout &
tee 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
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
- 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?
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. ;)
This should really be an engine feature, right? Pretty ”standard” as it were. ;)
Who is online
Users browsing this forum: Google [Bot] and 9 guests