PipedInputStream fromStdout;
ByteArrayOutputStream stderr;
public ScpChannel(ClientSession clientSession, String cmd) throws IOException {
this.toStdin = new PipedOutputStream();
this.fromStdout = new PipedInputStream();
log.debug("SCP Opening channel for cmd: " + cmd);
try {
channel = BugFixChannelExec.createExecChannel(clientSession, cmd, false);
} catch (Exception e1) {
throw new IOException("Cannot create channel", e1);
}
this.stderr = new ByteArrayOutputStream();
channel.setIn(new PipedInputStream(toStdin));
channel.setOut(new PipedOutputStream(fromStdout));
channel.setErr(stderr);
}