persistent local tty session with java

时光毁灭记忆、已成空白 提交于 2019-12-01 03:55:18

问题


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


回答1:


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.



来源:https://stackoverflow.com/questions/3357948/persistent-local-tty-session-with-java

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