I am using JLine 2 (v2.13) in conjunction with a Socket IO to create an admin console for my app which can be accessed via an ordinary telnet client. However I found it prints out strange symbols when it should print out a line break:
act.app.restart restart app^Jact.job.list List jobs
The correct output should be:
act.app.restart restart app
act.job.list List jobs
I traced into the code and found the following line of code that caused the trouble:
Another weird thing is when I press the up arrow to get the history, the console prints out ^[[A
and nothing else happens.
Does anyone have any idea?
Update: added relevant source code
- The code accepting the incoming telnet connection:
- The code that creates the
ConsoleReader
and dispatches the command:
Update 2
Sorry I've disappeared for a while. Just come back as my project gives me a breath of fresh air. So here is what happened: I've created a PrintWriter
and use it as a workaround for the ^J
issue:
However there are many other issues when jline2
is used along with telnet session:
- Type
<TAB>
displays tab instead of activate complete list. However after I hit enter key it gives me a complete list plus an error message: - Type
<UP>
arrow, displays^[[A
, hit enter key it will execute my last command. However I lost the command line editing
The issue is still there and I believe there should be a way to solve it just need some guide...
TelnetTerminal
is someone I want to implement, however it's not finished because I don't have the ideal how to deal with it. I didn't pass my Terminal to theConsoleReader
constructor and it just use theTerminalFactory.get()
to get an arbitrary terminal. In my system it will be thejline.UnixTerminal
. I just don't know how to configure it to make it work. I will create a simple project to demonstrate it – Tipistty --all
in the terminal window on the unix client to see what the configuration is. For sockets you should probably make sure you are in 8 bit raw mode. – Salesin24
(see pcmicro.com/netfoss/telnet.html for more info). – Blackhead24
option? I mean which API should I use? – Tipi