Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

persistent local tty session with java

Tags:

java

shell

tty

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

like image 753
Rigoni Avatar asked Jul 28 '10 22:07

Rigoni


1 Answers

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.

like image 137
Scott Avatar answered Nov 15 '22 17:11

Scott