private static void cleanup(ChannelExec exec) { if (exec != null) { try { exec.disconnect(); } catch (Throwable t) { LOG.warn("Couldn't disconnect ssh channel", t); } } }
/** * * {@link org.apache.commons.vfs2.provider.sftp.SftpFileSystem#executeCommand(java.lang.String, java.lang.StringBuilder) } */ private int executeCommand( String command, StringBuilder output ) throws JSchException, IOException { this.ensureSession(); ChannelExec channel = (ChannelExec) this.session.openChannel( "exec" ); channel.setCommand( command ); channel.setInputStream( (InputStream) null ); InputStreamReader stream = new InputStreamReader( channel.getInputStream() ); channel.setErrStream( System.err, true ); channel.connect(); char[] buffer = new char[128]; int read; while ( ( read = stream.read( buffer, 0, buffer.length ) ) >= 0 ) { output.append( buffer, 0, read ); } stream.close(); while ( !channel.isClosed() ) { try { Thread.sleep( 100L ); } catch ( Exception exc ) { log.logMinimal( "Warning: Error session closing. " + exc.getMessage() ); } } channel.disconnect(); return channel.getExitStatus(); }
@Override public void destroy() { if (channel.isConnected()) channel.disconnect(); closeOutputStream(); }
@Override public void clear() { if (executor != null) executor.disconnect(); }
protected void cleanupPutTransfer( Resource resource ) { if ( channel != null ) { channel.disconnect(); channel = null; } }
protected void cleanupGetTransfer( Resource resource ) { if ( channel != null ) { channel.disconnect(); } }
@Override public void destroy() { channelExec.disconnect(); } }
@Override public void clear() { if (executor != null) executor.disconnect(); if (sessionConnection != null) sessionConnection.disconnect(); }
private static void cleanup(ChannelExec exec) { if (exec != null) { try { exec.disconnect(); } catch (Throwable t) { LOG.warn("Couldn't disconnect ssh channel", t); } } }
@Override public void clear() { if (executor != null) executor.disconnect(); if (sessionConnection != null) sessionConnection.disconnect(); }
@Override public void close() { if (channel != null) { channel.disconnect(); } if (session != null) { session.disconnect(); } }
@Override public void close() { if (channel != null) { channel.disconnect(); } if (session != null) { session.disconnect(); } }
@Override public void close() { if (channel != null) { channel.disconnect(); } if (session != null) { session.disconnect(); } }
private static void cleanup(ChannelExec exec) { if (exec != null) { try { exec.disconnect(); } catch (Throwable t) { LOG.warn("Couldn't disconnect ssh channel", t); } } }
private static void cleanup(ChannelExec exec) { if (exec != null) { try { exec.disconnect(); } catch (Throwable t) { LOG.warn("Couldn't disconnect ssh channel", t); } } }
@Override public void clear() { if (inputStream != null) Closeables.closeQuietly(inputStream); if (errStream != null) Closeables.closeQuietly(errStream); if (executor != null) executor.disconnect(); }
private void checkAck(ChannelExec channel, InputStream in) throws IOException { int returnCode = in.read(); if (returnCode != 0) { channel.disconnect(); throw new RuntimeException("SCP failed, error code: " + returnCode); } }
@Override public void destroy() { if (channel.isConnected()) channel.disconnect(); }
private static void cleanup(ChannelExec exec) { if (exec != null) { try { exec.disconnect(); } catch (Throwable t) { LOG.warn("Couldn't disconnect ssh channel", t); } } }