send arrow keys using ganymed ssh java

Posted by José Ramón Pérez Rubio on Stack Overflow See other posts from Stack Overflow or by José Ramón Pérez Rubio
Published on 2012-11-25T16:41:23Z Indexed on 2012/11/25 17:04 UTC
Read the original article Hit count: 354

Filed under:
|
|

I am using Ganymed ssh to connect to a remote machine and apart from sending commands I need to send the arrows keys (left and right keys). I can send commands but when I send the arrows keys nothing happends. This is what I have:

public boolean createShell() throws Exception
{
    try
    {
      //   ...       
        m_session= connection.openSession();
        m_commandWriter = new OutputStreamWriter(m_session.getStdin());

        String encoding=m_commandWriter.getEncoding();
        //encoding is UFT8

        m_errorPipe=new SSHSyncPipe(m_session.getStderr());
        m_outputPipe=new SSHSyncPipe(m_session.getStdout());


        m_outputPipe.start();
        m_errorPipe.start();

       // m_session.requestPTY("bash");
        m_session.requestDumbPTY();
        m_session.startShell();

        m_shellCreated=true;
        return true;
    }
}

So if I use

m_commandWriter.write(ls"\r\n");
m_commandWriter.flush();

It works, but

m_commandWriter.write(37);//37 is the code for left arrow
m_commandWriter.flush();

Doesn't work.

Does anyone know what I am doing wrong? Thank you

© Stack Overflow or respective owner

Related posts about java

Related posts about ssh