Let me see if I could put some more details around this.

So I have two problems. I think they are around PtyModes.

1. The carriage return is not honored no matter what I options I use. I’m just 
simply trying to get it to work in Mac/Linux environment. Unless I specifically 
add \r\n it does not want to work.
2. When I type in a regular SSH session, I see characters as I type them. In 
Apache SSHD, I don’t see my input, but once I enter, it does send it over for 
execution.

So I have created a custom ShellFactory and Command, that will execute Java 
code on the input provided in the shell.

  private class CLIShellFactory implements ShellFactory  {

    public Command createShell(ChannelSession channelSession) {
      return new CLIShell();
    }

    private class CLIShell implements Command, Runnable {

At first I was using regular InputStream and OutpuStream, but then I saw some 
code using TtyFilterInputStream and TtyFilterOutputStream, so I tried to 
convert my code to use these, and provide PtyModes. But I’m still having issues 
with it. Also, the TtyFilterOutputStream requires the following for echo to 
work:

public TtyFilterOutputStream(OutputStream out, TtyFilterInputStream echo, 
Collection<PtyMode> ttyOptions) {

If I use TtyFilterInputStream echo and set my InputStream, I will get into an 
infinite loop! So I have set it to null, and removed PtyMode.ECHO, but I do 
need it.

Any light on what I’m doing wrong here?

Is there a ShellFactory where I can just override one method and execute my 
custom Java code which will enable me to have proper new lines and carriage 
returns and echo enabled?

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.

I did find this that I think has similar problem, which was old thread:

http://apache-mina.10907.n7.nabble.com/sshd-clients-and-echo-td28501.html 
<http://apache-mina.10907.n7.nabble.com/sshd-clients-and-echo-td28501.html>

Hope someone can help…

Regards,
Oskar

> On Oct 21, 2020, at 7:13 PM, Oskar Z <[email protected]> wrote:
> 
> 
> 
>> On Oct 21, 2020, at 3:40 PM, Oskar Z <[email protected] 
>> <mailto:[email protected]>> wrote:
>> 
>> Hello,
>> 
>> Hope someone can help or point in the right direction.
>> 
>> I have created my custom ShellFactory and Command, and commands get executed 
>> fine in-app, but the problem is formatting of output, and I cannot see what 
>> I type until I hit “enter” and output is not seen until I use out.flush().
>> 
>> It seems to have some tabs…..
>> 
>> NodeID, TypeName, OperatorActions, Links
>>                                         -----------------------
>>                                                                
>> Types,Types,com.micromuse.response.common.TypeOrgNodeIdentifier#com.micromuse.response.dblayer.TypeOrgNode#9900#Types#Types,Types,
>>                                                                              
>>                                                                              
>>                                        ,Link Types: 
>>                                                                              
>>                                                                              
>>                                                     ENDRECORD
>> 
>>         READY
>>              Execution Failed. Check impactserver.log for details.
>>                                                                   READY
>>                              
>>                                                                              
>>                 READY
>>                                                                              
>>                                                         READY
>> 
>> Thanks,
>> Oskar
>> 
> 

Reply via email to