Redirecting stdin through a FIFO

不打扰是莪最后的温柔 提交于 2019-12-12 20:01:47

问题


I'm running a server app (written in Java) under GNU/Linux which takes input (from stdin, I guess) and interprets it to run some commands. I dont want to run the app inside a terminal window (I'd like to run a daemon), but I'd still like to be able to input commands whenever I want to. I thought I might be able to do that using fifos, so I created it using mknod. The problem is cat fifofile > java... and cat fifofile | java ... fail with a "file not found" error for some reason.

Using only cat to read and write and the fifo works flawlessly.

Is there any way to fix this, or any other way to achieve the same goal?


回答1:


So, Minecraft? The best way to do this is to have a bona-fide tty for the console part of the application. screen is an easy way to do that.




回答2:


Have you tried java < fifofile? What about something like exec 3<&0; exec 0<fifofile; java?

What shell are you using? You might be able to use process substitution or coprocesses if you're using a shell that supports them.



来源:https://stackoverflow.com/questions/4559291/redirecting-stdin-through-a-fifo

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!