@Signature public void command(String command) { getWrappedObject().setCommand(command); }
/** * Create a new sftp channel to execute commands. * * @param command to execute on the remote machine * @return a new execution channel * @throws SftpException if a channel could not be opened */ public ChannelExec getExecChannel(String command) throws SftpException { ChannelExec channelExec; try { channelExec = (ChannelExec) this.session.openChannel("exec"); channelExec.setCommand(command); channelExec.connect(); return channelExec; } catch (JSchException e) { throw new SftpException(0, "Cannot open a channel to SFTP server", e); } }
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
((ChannelExec) channel).setCommand(command);
try { channel = session.openChannel( "exec" ); ( ( ChannelExec ) channel ).setCommand( command.getCommand() ); channel.connect();
/** * * {@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(); }
((ChannelExec) channel).setCommand(command);
( ( ChannelExec ) channel ).setCommand( exec );
ch = (ChannelExec)ses.openChannel("exec"); ch.setCommand(cmd);
/** * 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); } }
channel.setCommand(StrUtil.bytes(cmd, charset)); channel.setInputStream(null); channel.setErrStream(errStream);
channel.setCommand(StrUtil.bytes(cmd, charset)); channel.setInputStream(null); channel.setErrStream(errStream);
channel.setCommand(sshMeta.getCommandLine());
try { channel = (ChannelExec) sock.openChannel("exec"); //$NON-NLS-1$ channel.setCommand(commandName); setupStreams(); channel.connect(timeout > 0 ? timeout * 1000 : 0);