sshSession.execCommand(cmd);
sess.execCommand(command);
logDetailed( BaseMessages.getString( PKG, "SSH.Log.RunningCommand", data.commands ) ); session.execCommand( data.commands );
public void execCommand(String command) throws IOException { mySession.execCommand(command); }
s.execCommand(commandName);
private static void putDir(Connection conn, String localDirectory, String remoteTargetDirectory, String mode) throws IOException { final String[] fileList = curDir.list(); for (String file : fileList) { final String fullFileName = localDirectory + "/" + file; if (new File(fullFileName).isDirectory()) { final String subDir = remoteTargetDirectory + "/" + file; Session sess = conn.openSession(); sess.execCommand("mkdir " + subDir); sess.waitForCondition(ChannelCondition.EOF, 0); putDir(conn, fullFileName, subDir, mode); } else { SCPClient scpc = conn.createSCPClient(); scpc.put(fullFileName, remoteTargetDirectory, mode); } } }
sess.execCommand(cmd); sendBytes(sess, data, remoteFileName, mode);
sess.execCommand(cmd); sendFiles(sess, localFiles, remoteFiles, mode);
sess.execCommand(cmd); sendBytes(sess, data, remoteFileName, mode);
sess.execCommand(cmd); receiveFiles(sess, targets);
sess.execCommand(cmd); receiveFiles(sess, targets);
sess.execCommand(cmd); sendBytes(sess, data, remoteFileName, mode);
sess.execCommand(cmd); receiveFiles(sess, targets);
@Override public void execCmd(RemoteCmd cmd) { List<String> cmds = cmd.getCmds(); String ip = remoteCmdClientConfig.getIp(); Session session = null; for (String commandLine : cmds) { try { session = connection.openSession(); session.execCommand(commandLine); } catch (IOException e) { log.error(String.format("Close session %s failed!", ip)); } finally { if (session != null) { session.close(); } } } }
public Channel launchChannel(String[] cmd, OutputStream out, FilePath _workDir, Map<String, String> envVars) throws IOException, InterruptedException { printCommandLine(cmd, _workDir); final Session session = connection.openSession(); session.execCommand(makeCommandLine(Arrays.asList(cmd), _workDir)); return new Channel("channel over ssh on "+connection.getHostname()+":"+connection.getPort(), Computer.threadPoolForRemoting, session.getStdout(), new BufferedOutputStream(session.getStdin())); }
public Channel launchChannel(String[] cmd, OutputStream out, FilePath _workDir, Map<String, String> envVars) throws IOException, InterruptedException { printCommandLine(cmd, _workDir); final Session session = connection.openSession(); session.execCommand(makeCommandLine(Arrays.asList(cmd), _workDir)); return new Channel("channel over ssh on "+connection.getHostname()+":"+connection.getPort(), Computer.threadPoolForRemoting, session.getStdout(), new BufferedOutputStream(session.getStdin())); }
@Override public RemoteCmdClientStream execCmdGetStream(RemoteCmd cmd) { Session session = null; String ip = remoteCmdClientConfig.getIp(); if (!isReady()) { log.error(String.format("remoteCmdClient %s is not ready!", ip)); return new RemoteCmdClientStream(null, ip); } try { session = connection.openSession(); } catch (IOException e) { log.error(String.format("Open session %s failed!", ip)); return new RemoteCmdClientStream(null, ip); } try { session.execCommand(cmd.getCmd()); } catch (IOException e) { log.error(String.format("execCommand %s failed!", ip)); return new RemoteCmdClientStream(null, ip); } return new RemoteCmdClientStream(session, ip); }
session.execCommand(cmd);
session.execCommand(cmd);
/** * Executes a process remotely and blocks until its completion. * * @param command the command * @param output The stdout/stderr will be sent to this stream. * @return the int * @throws IOException the io exception * @throws InterruptedException the interrupted exception */ public int exec(String command, OutputStream output) throws IOException, InterruptedException { Session session = openSession(); try { session.execCommand(command); PumpThread t1 = new PumpThread(session.getStdout(), output); t1.start(); PumpThread t2 = new PumpThread(session.getStderr(), output); t2.start(); session.getStdin().close(); t1.join(); t2.join(); // wait for some time since the delivery of the exit status often gets delayed session.waitForCondition(ChannelCondition.EXIT_STATUS,3000); Integer r = session.getExitStatus(); if(r!=null) return r.intValue(); return -1; } finally { session.close(); } }