I have made some more progress, not sure if this will work for all cases, but it works on MacOS and Linux.
I had to extend TtyFilterOutputStream with my own class / methods to handleLF and handleCR. So the output looks fine: READY STARTRECORD Status ----------------------- Running: 1 Sessions ENDRECORD READY STARTRECORD Key, Name, OrgNodeID, TypeName, OperatorActions, Links ----------------------- Types,Types,TypeOrgNode#9900#Types#Types,Types,,Link Types: XYZ ENDRECORD But now the issue is how do I get the ECHO to work! When I type my command, I need to see what I type, as soon as I type a character, just like in any normal terminal. I understand how the ProcessShell works, as the process has Input, Output and Error (which is used as Echo stream) streams, but in this case I have Input and Output only, and don’t have a Process. What happens now, is as I type I don’t see anything, then I press ‘Enter’ and it gets read in and gets executed correctly, so what I have to do is type it up in Text editor and then copy/paste the command into the Terminal. Please help! Thank you, Oskar > On Oct 27, 2020, at 1:15 PM, Oskar Z <oska...@yahoo.com> wrote: > > Thanks! So looks like the issue is still unresolved. > > I think this is very critical. > > So I have made some progress, but now everything is written to the same line, > no matter what. > > I’m using the following PTY options: > > PtyMode.ONLCR > PtyMode.OCRNL > PtyMode.ONOCR > PtyMode.ECHO > PtyMode.INLCR > PtyMode.ICRNL > > And using the following constructors: > > CmdLineServiceHandler(CLIShellFactory.CLIShell shell) throws IOException { > super("Command line server handler"); > //PtyMode.ONLCR, PtyMode.OCRNL, PtyMode.ONLRET, PtyMode.ONOCR > //PtyMode.ECHO, PtyMode.INLCR, PtyMode.ICRNL, PtyMode.IGNCR > Set<PtyMode> mode_options = > Collections.unmodifiableSet(EnumSet.of(PtyMode.ONLCR, PtyMode.OCRNL, > PtyMode.ONOCR, PtyMode.ECHO, PtyMode.INLCR, PtyMode.ICRNL)); > TtyFilterInputStream echoStream = new > TtyFilterInputStream(shell.getInputStream(), mode_options); > input = new BufferedReader(new InputStreamReader(new > TtyFilterInputStream(shell.getInputStream(), mode_options))); > output = new PrintStream(new > TtyFilterOutputStream(shell.getOutputStream(), echoStream, mode_options), > true); > //input = new BufferedReader(new > InputStreamReader(shell.getInputStream())); > //output = new PrintStream(shell.getOutputStream()); > > Any idea on correct PTY options? I tried InteractiveProcessShellFactory.java > <https://github.com/apache/mina-sshd/blob/master/sshd-core/src/main/java/org/apache/sshd/server/shell/InteractiveProcessShellFactory.java> > and it seems to work, but not with my Custom Shell and Command. > > Thanks, > Oskar > >> On Oct 27, 2020, at 12:53 PM, Lyor Goldstein <lgoldst...@apache.org >> <mailto:lgoldst...@apache.org>> wrote: >> >>>> I would really appreciate someone who has experience with this to give >> me some guidance. I have searched the web and cannot seem to find anything. >> >>>> Hope someone can help… >> >> This is an oldie but goodie - we have made several attempts in the past >> (see SSHD-897 SSHD-1029) but we always come up short since there seem to be >> many behavior variations on the sent escape sequence and echo options... >