@Signature public InputStream getErrorStream() throws IOException { return getWrappedObject().getErrStream(); }
( ( ChannelExec ) channel ).getErrStream() ) );
InputStream err = ((ChannelExec) channel).getErrStream();
/** * Execute a command through the ssh session, pumping its * stderr and stdout to our own logs. */ private int execCommand(Session session, String cmd) throws JSchException, InterruptedException, IOException { LOG.debug("Running cmd: " + cmd); ChannelExec exec = null; try { exec = (ChannelExec)session.openChannel("exec"); exec.setCommand(cmd); exec.setInputStream(null); exec.connect(); // Pump stdout of the command to our WARN logs StreamPumper outPumper = new StreamPumper(LOG, cmd + " via ssh", exec.getInputStream(), StreamPumper.StreamType.STDOUT); outPumper.start(); // Pump stderr of the command to our WARN logs StreamPumper errPumper = new StreamPumper(LOG, cmd + " via ssh", exec.getErrStream(), StreamPumper.StreamType.STDERR); errPumper.start(); outPumper.join(); errPumper.join(); return exec.getExitStatus(); } finally { cleanup(exec); } }
private void setupStreams() throws IOException { inputStream = channel.getInputStream(); // JSch won't let us interrupt writes when we use our InterruptTimer // to break out of a long-running write operation. To work around // that we spawn a background thread to shuttle data through a pipe, // as we can issue an interrupted write out of that. Its slower, so // we only use this route if there is a timeout. OutputStream out = channel.getOutputStream(); if (timeout <= 0) { outputStream = out; } else { IsolatedOutputStream i = new IsolatedOutputStream(out); outputStream = new BufferedOutputStream(i, 16 * 1024); } errStream = channel.getErrStream(); }
InputStream err = ((ChannelExec) channel).getErrStream();
protected ChannelResponse(InputStream response, ChannelExec channel) throws IOException, JSchException { this.channel = channel; // ATTENTION: stream must be get before connecting this.channelInputStream = response; this.channelErrorStream = channel.getErrStream(); }
/** * Returns the STDERR stream for you to read from. No need to close this * stream independently, instead, when done with all processing, call * {@link #close()}; * * @return The STDERR stream * @throws IOException * If unable to read from the stream */ public InputStream getErrStream() throws IOException { if ( stdErr == null ) { stdErr = channel.getErrStream(); } return stdErr; }
@Override public String call() throws Exception { StringBuilder builder = new StringBuilder(); Reader in = reader(channel.getErrStream(), "UTF-8"); try { copy(in, builder); } finally { in.close(); } return builder.toString(); } });
JSchCliProcess(Session session, ChannelExec channel) throws IOException { super(channel.getInputStream(), channel.getErrStream(), channel.getOutputStream()); this.session = session; this.channel = channel; }
public synchronized void bind(final Channel aChannel) throws Exception { m_aStdOut = aChannel.getInputStream(); if (aChannel instanceof ChannelExec) m_aStdErr = ((ChannelExec) aChannel).getErrStream(); start (); }
JSchCliProcess(Session session, ChannelExec channel) throws IOException { super(channel.getInputStream(), channel.getErrStream() , channel.getOutputStream()); this.session = session; this.channel = channel; }
public synchronized void bind(final Channel aChannel) throws Exception { m_aStdOut = aChannel.getInputStream(); if (aChannel instanceof ChannelExec) m_aStdErr = ((ChannelExec) aChannel).getErrStream(); start (); }
@Override public ChannelExec create() throws Exception { checkConnected(); String channel = "exec"; executor = (ChannelExec) sessionConnection.getSession().openChannel(channel); executor.setPty(true); executor.setCommand(command); inputStream = executor.getInputStream(); errStream = executor.getErrStream(); executor.connect(); return executor; }
@Override public ChannelExec create() throws Exception { checkConnected(); String channel = "exec"; executor = (ChannelExec) sessionConnection.getSession().openChannel(channel); executor.setPty(true); executor.setCommand(command); inputStream = executor.getInputStream(); errStream = executor.getErrStream(); executor.connect(); return executor; }
@Override public ChannelExec create() throws Exception { checkConnected(); String channel = "exec"; executor = (ChannelExec) sessionConnection.getSession().openChannel(channel); executor.setPty(true); executor.setCommand(command); inputStream = executor.getInputStream(); errStream = executor.getErrStream(); executor.connect(); return executor; }
public void runCommand(String command) { ChannelExec channel = (ChannelExec)session.openChannel("exec"); channel.setCommand(command); try (InputStream stdOut = channel.getInputStream(); InputStream stdErr = channel.getErrStream()) { channel.connect(TIMEOUT); // read from stdOut and stdErr } channel.disconnect(); }
/** * Close the streams belonging to the given Process. * * @param process * the <code>Process</code>. * @throws IOException */ public static void closeStreams(ChannelExec process) throws IOException { FileUtils.close(process.getInputStream()); FileUtils.close(process.getOutputStream()); FileUtils.close(process.getErrStream()); }
private void attachStreams(final ChannelExec channel) throws IOException { streamHandler.setProcessInputStream(channel.getOutputStream()); streamHandler.setProcessOutputStream(channel.getInputStream()); streamHandler.setProcessErrorStream(channel.getErrStream()); streamHandler.start(); }
public void openStreams(ChannelExec exec, String encoding) throws IOException { Assert.isFalse(open, "Already open"); Assert.noNulls(exec); this.inputFeeder = getInputFeeder(context, exec); this.outputPumper = new StreamPumper(exec.getInputStream(), encoding, context.getStdout()); this.errorPumper = new StreamPumper(exec.getErrStream(), encoding, context.getStderr()); this.open = true; }