Hello,
I have written an implementation of CommandFactory for my SSH server (by
using Mina SSHD 0.8.0) and I'm asking a small question. On my OpenSSH
client I get the output stream, only when the command exists. However,
this command is very long (and sometimes blocks ;)) and I would like to
have the output on the fly. When I use a "shell" channel, I have no problem.
Here is my implementation of the method
org.apache.sshd.server.Command::start(Environment):
public void start(final Environment env) throws IOException {
int returnCode = 0;
String message = null;
PrintStream pout = new PrintStream(out, true);
PrintStream perr = new PrintStream(err, true);
try {
final CommandSession session =
commandProcessor.createSession(in, pout, perr);
session.execute(command);
} catch (Exception e) {
returnCode = 1;
message = e.getMessage();
perr.println(message);
throw (IOException) new IOException("Unable to execute
the command").initCause(e);
} finally {
close(in, pout, perr);
callback.onExit(returnCode, message);
}
}
The classes CommandProcessor and CommandSession are provided by Apache
Felix Gogo.
With an exec channel, I can see that the flush is performed only once
time (when exiting), in the method
org.apache.mina.core.polling.AbstractPollingIoProcessor::flush.
Do you have an idea, please, of how to enable a kind of auto-flush for
the output stream when using the exec channel ?
Cheers,
Loris