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(); }
channel.setInputStream(null, true); OutputStream out = channel.getOutputStream(); channel.setOutputStream(System.out, true); channel.setExtOutputStream(System.err, true);
/** * Returns the STDIN stream for you to write to. No need to close this * stream independently, instead, when done with all processing, call * {@link #close()}; * * @return The STDIN stream * @throws IOException * If unable to write to the stream */ public OutputStream getOutputStream() throws IOException { if ( stdIn == null ) { stdIn = channel.getOutputStream(); } return stdIn; } }
/** * Returns the STDIN stream for you to write to. No need to close this * stream independently, instead, when done with all processing, call * {@link #close()}; * * @return The STDIN stream * @throws IOException * If unable to write to the stream */ public OutputStream getOutputStream() throws IOException { if ( stdIn == null ) { stdIn = channel.getOutputStream(); } return stdIn; } }
@Override public OutputStream getOutputStream() { try { return channel.getOutputStream(); } catch (final IOException e) { throw new IllegalStateException("IOException getting the SSH proxy output stream", e); } }
@Override public OutputStream getOutputStream() { try { return channel.getOutputStream(); } catch (final IOException e) { throw new IllegalStateException("IOException getting the SSH proxy output stream", e); } }
@Override public OutputStream getOutputStream() { try { return channel.getOutputStream(); } catch (final IOException e) { throw new IllegalStateException("IOException getting the SSH proxy output stream", e); } }
@Override public OutputStream getOutputStream() { try { return channel.getOutputStream(); } catch (final IOException e) { throw new IllegalStateException("IOException getting the SSH proxy output stream", e); } }
@Override public OutputStream openStandardInput() throws IOException { LOG.debug("Opening remote standard input: {}", command); return channel.getOutputStream(); }
@Override public OutputStream getOutputStream() { log.debug("ssh proxy getOutputStream()"); try { return channel.getOutputStream(); } catch (IOException e) { throw new UncheckedIOException("IOException getting the SSH proxy outputstream", e); } }
ChannelExec deployWarFile = (ChannelExec)session.openChannel("exec"); deployWarFile.setCommand("/path/to/count-the-bytes"); OutputStream deployWarFileStdin = deployWarFile.getOutputStream(); InputStream deployWarFileStdout = new BufferedInputStream(deployWarFile.getInputStream()); InputStream warFileInputStream = new FileInputStream(warFile); deployWarFile.connect(); IOUtils.copy(warFileInputStream, deployWarFileStdin); deployWarFileStdin.close(); warFileInputStream.close(); IOUtils.copy(deployWarFileStdout, System.out); deployWarFileStdout.close();
protected Optional<StreamFeeder> getInputFeeder(CommandContext context, ChannelExec exec) throws IOException { if (context.getStdin().isPresent()) { StreamFeeder feeder = new StreamFeeder(context.getStdin().get(), exec.getOutputStream()); return Optional.of(feeder); } else { return Optional.absent(); } }
JSchCliProcess(Session session, ChannelExec channel) throws IOException { super(channel.getInputStream(), channel.getErrStream() , channel.getOutputStream()); this.session = session; this.channel = channel; }
JSchCliProcess(Session session, ChannelExec channel) throws IOException { super(channel.getInputStream(), channel.getErrStream(), channel.getOutputStream()); this.session = session; this.channel = channel; }
@Override public Void call() throws Exception { Writer out = writer(channel.getOutputStream(), "UTF-8"); try { copy(reader(input), out); } finally { out.close(); } return null; } });
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(); }
private void write(ChannelExec c, String name, InputStream data, ScpConfiguration cfg) throws IOException { OutputStream os = c.getOutputStream(); InputStream is = c.getInputStream(); try { writeFile(name, data, os, is, cfg); } finally { IOHelper.close(is, os); } }
protected static void doSingleTransfer(Session session, File localFile, String remoteFilePath) throws IOException, JSchException, SSHException { String command = "scp -t \"" + remoteFilePath + "\""; ChannelExec channel = (ChannelExec) session.openChannel("exec"); channel.setCommand(command); try { OutputStream out = channel.getOutputStream(); InputStream in = channel.getInputStream(); channel.connect(); waitForAck(in); sendFileToRemote(localFile, in, out); } finally { 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(); }