How to get STDOUT and STDIN of a server?

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

How to get STDOUT and STDIN of a server?

by texmex » Sat Jul 20, 2019 08:23

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: 376
Joined: Sun Jan 15, 2017 09:04

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

by Chiantos » Sat Jul 20, 2019 09:25

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

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

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

by orwell » Sat Jul 20, 2019 11:41

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: 1623
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: texmex

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

by texmex » Sat Jul 20, 2019 12:46

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


Return to General Discussion



Who is online

Users browsing this forum: MSN [Bot] and 4 guests