Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在开发一个 Web shell 客户端,具有选项卡功能“代码完成”和一个问题。任何人都知道一种打开本地 tty 持久连接的方法,我可以在一个会话中执行多个命令,我不想一直执行 Runtime.getRuntime().exec("command"); 有什么建议吗?问候
而不是Runtime.getRuntime().exec("command");做Runtime.getRuntime().exec("/bin/sh");并坚持Process对象。然后您可以将命令写入其getOutputStream()方法提供的 OutputStream - 我假设您已经通过读取其 InputStream 获得了输出。
Runtime.getRuntime().exec("command");
Runtime.getRuntime().exec("/bin/sh");
Process
getOutputStream()