I'm trying to create a simple shell that takes the input and echoes it back. I
thought in the start method, I could create a thread that simply read int from
the inputstream and wrote to the outputstream. However, I notice that when I
start typing in putty, everything is ignored (SSH_MSG_IGNORE) and nothing makes
its way to my shell.
Perhaps my shell code is too simple? Can anyone provide a sample? Here is my
Shell implementation:
public class SimpleShell implements Shell, Runnable {
private OutputStream _errorStream;
private InputStream _inputStream;
private OutputStream _outputStream;
public void destroy() {
}
public void setErrorStream(OutputStream stream) {
_errorStream = stream;
}
public void setExitCallback(ExitCallback arg0) {
}
public void setInputStream(InputStream stream) {
_inputStream = stream;
}
public void setOutputStream(OutputStream stream) {
_outputStream = stream;
}
public void start(Environment arg0) throws IOException {
Thread thread = new Thread(this);
thread.start();
_outputStream.write("Hello> ".getBytes());
_outputStream.flush();
}
public void run() {
int i = 0;
try {
while ((i = _inputStream.read()) != -1) {
_outputStream.write(i);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}