Executing screen command from Java

别来无恙 提交于 2019-12-11 15:11:55

问题


I am using the following code to execute an SH file in Linux

Runtime.getRuntime().exec(new String[] { "/bin/sh", "-c", file.getPath() });

This code works however I can't use the screen command in the SH file when executing it from Java, I get this error

Must be connected to a terminal.

So is it possible to "connect" java to a terminal? I would like to be able to also view this screen when I connect via SSH so I think it has to be connected to the terminal that is shown when you SSH into the server.


回答1:


I found that if I use screen -dm it will work. Thanks!



来源:https://stackoverflow.com/questions/15041515/executing-screen-command-from-java

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