通过FIFO重定向标准输入 [英] Redirecting stdin through a FIFO

查看:122
本文介绍了通过FIFO重定向标准输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在GNU/Linux下运行一个服务器应用程序(用Java编写),该应用程序会接收输入(我想是从stdin输入),并将其解释为运行一些命令.我不想在终端窗口中运行该应用程序(我想运行一个守护程序),但是我仍然希望能够随时输入命令.我以为我可以使用fifos做到这一点,所以我使用mknod创建了它.问题是 cat fifofile> java ... cat fifofile | java ... 由于某种原因而失败,并显示找不到文件"错误.

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.

仅使用猫来读写,fifo即可正常工作.

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?

推荐答案

那么,我的世界吗?最好的方法是为应用程序的控制台部分提供一个真正的tty. 屏幕是一种简单的方法.

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.

这篇关于通过FIFO重定向标准输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆