【发布时间】:2016-12-21 18:36:58
【问题描述】:
我想在我自己的 java 应用程序中读取正在运行的应用程序的所有输出。目前我有 2 个屏幕,第一个是输出应用程序永久打印新信息,第二个是 java 应用程序。不幸的是,不可能在一个屏幕上同时运行两个应用程序。我的想法是将所有输出通过管道传输到 java 应用程序屏幕以在那里读取它,但我做错了或者它不起作用。
我的(测试)服务器如下所示:
public class Main {
public static void main(String[] args) throws InterruptedException {
while (true) {
Scanner scanner = new Scanner(System.in);
String output = scanner.next();
System.out.print("JAVA " + output);
}
}
}
我的 linux 启动文件是这样的:
#!/bin/bash
cd ../../raspberry-remote/
screen -dmS smarthome_javaserver #here runns the java application
screen -dmS smarthome_receive | smarthome_javaserver #send the output to the java screen
#start java app
screen -S smarthome_javaserver -p 0 -X stuff "java -jar ServerReceiver.jar^M"
#start receive tool
screen -S smarthome_receive -p 0 -X stuff "pilight-daemon -D^M"
screen -S smarthome_receive -p 0 -X stuff "pilight-daemon -D^M"
echo "started receiver"
任何人都知道如何实现这一点,或者有没有办法让它们在一个屏幕上运行?感谢您的帮助。
【问题讨论】:
标签: java linux debian gnu-screen