与java持久的本地tty会话 [英] persistent local tty session with java
问题描述
我正在开发一个Web shell客户端,其标签功能代码完成并且有一个问题。
任何人都知道打开本地tty持久连接的方法,我可以用一个会话执行多个命令,我不喜欢执行所有时间Runtime.getRuntime()。exec(command);
有什么建议吗?
问候
I`m developing a web shell client, with tab functionality "code completion" and a have a question. Anyone know a way to open a local tty persistent connection where I can to execute multiple commands with one session, i wont like to exec all time Runtime.getRuntime().exec("command"); Any suggestion? Regards
推荐答案
而不是 Runtime.getRuntime()。exec(command) ;
执行运行时.getRuntime()。exec(/ bin / sh);
并保持进程
对象。然后你可以将命令写入由它的 getOutputStream()
方法提供的OutputStream - 我假设你已经通过读取它的InputStream来获取输出。
Instead of Runtime.getRuntime().exec("command");
do Runtime.getRuntime().exec("/bin/sh");
and hold on to the Process
object. Then you can write commands to the OutputStream provided by its getOutputStream()
method - I presume you're already getting the output by reading its InputStream.
这篇关于与java持久的本地tty会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!