问题
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