private void copyRemote(String localFile, String destDir) throws IOException { SSHClient ssh = new SSHClient(remoteHost, port, remoteUser, remotePwd); try { ssh.scpFileToRemote(localFile, destDir); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private Pair<Integer, String> runRemoteCommand(String command, Logger logAppender) throws IOException { SSHClient ssh = new SSHClient(remoteHost, port, remoteUser, remotePwd); SSHClientOutput sshOutput; try { sshOutput = ssh.execCommand(command, remoteTimeoutSeconds, logAppender); int exitCode = sshOutput.getExitCode(); String output = sshOutput.getText(); return Pair.newPair(exitCode, output); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
@Test public void testScp() throws Exception { if (isRemote == false) return; SSHClient ssh = new SSHClient(this.hostname, this.port, this.username, this.password); File tmpFile = File.createTempFile("test_scp", "", new File("/tmp")); tmpFile.deleteOnExit(); FileUtils.write(tmpFile, "test_scp", Charset.defaultCharset()); ssh.scpFileToRemote(tmpFile.getAbsolutePath(), "/tmp"); } }
@Test public void testCmd() throws Exception { if (isRemote == false) return; SSHClient ssh = new SSHClient(this.hostname, this.port, this.username, this.password); SSHClientOutput output = ssh.execCommand("echo hello"); assertEquals(0, output.getExitCode()); assertEquals("hello\n", output.getText()); }
private void copyRemote(String localFile, String destDir) throws IOException { SSHClient ssh = new SSHClient(remoteHost, remoteUser, remotePwd); try { ssh.scpFileToRemote(localFile, destDir); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private Pair<Integer, String> runRemoteCommand(String command, Logger logAppender) throws IOException { SSHClient ssh = new SSHClient(remoteHost, remoteUser, remotePwd); SSHClientOutput sshOutput; try { sshOutput = ssh.execCommand(command, remoteTimeoutSeconds, logAppender); int exitCode = sshOutput.getExitCode(); String output = sshOutput.getText(); return new Pair<Integer, String>(exitCode, output); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
@Test public void testScp() throws Exception { if (isRemote == false) return; SSHClient ssh = new SSHClient(this.hostname, this.username, this.password); File tmpFile = FileUtil.createLocalTempFile(new File("/tmp/test_scp"), "temp_", false); ssh.scpFileToRemote(tmpFile.getAbsolutePath(), "/tmp"); } }
public void downloadToLocal() throws IOException { String localArchive = "../examples/test_case_data/minicluster/hbase-export.tar.gz"; if (kylinConfig.getRunAsRemoteCommand()) { SSHClient ssh = new SSHClient(kylinConfig.getRemoteHadoopCliHostname(), kylinConfig.getRemoteHadoopCliUsername(), kylinConfig.getRemoteHadoopCliPassword()); try { ssh.scpFileToLocal(backupArchive, localArchive); } catch (Exception e) { e.printStackTrace(); } } else { FileUtils.copyFile(new File(backupArchive), new File(localArchive)); } }
public void uploadTarballToRemote() throws IOException { cli.execute("mkdir -p /tmp/hbase-export/"); @SuppressWarnings("unused") SSHClient ssh = new SSHClient(kylinConfig.getRemoteHadoopCliHostname(), kylinConfig.getRemoteHadoopCliUsername(), kylinConfig.getRemoteHadoopCliPassword()); try { // ssh.scpFileToRemote("../examples/test_case_data/minicluster/hbase-export.tar.gz", importFolder); } catch (Exception e) { e.printStackTrace(); } cli.execute("tar -xzf /tmp/hbase-export/hbase-export.tar.gz --directory=" + importFolder); }
@Test public void testCmd() throws Exception { if (isRemote == false) return; SSHClient ssh = new SSHClient(this.hostname, this.username, this.password); SSHClientOutput output = ssh.execCommand("echo hello"); assertEquals(0, output.getExitCode()); assertEquals("hello\n", output.getText()); }
private void copyRemote(String localFile, String destDir) throws IOException { SSHClient ssh = new SSHClient(remoteHost, remoteUser, remotePwd); try { ssh.scpFileToRemote(localFile, destDir); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private void copyRemote(String localFile, String destDir) throws IOException { SSHClient ssh = new SSHClient(remoteHost, port, remoteUser, remotePwd); try { ssh.scpFileToRemote(localFile, destDir); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private Pair<Integer, String> runRemoteCommand(String command, Logger logAppender) throws IOException { SSHClient ssh = new SSHClient(remoteHost, port, remoteUser, remotePwd); SSHClientOutput sshOutput; try { sshOutput = ssh.execCommand(command, remoteTimeoutSeconds, logAppender); int exitCode = sshOutput.getExitCode(); String output = sshOutput.getText(); return Pair.newPair(exitCode, output); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }
private Pair<Integer, String> runRemoteCommand(String command, Logger logAppender) throws IOException { SSHClient ssh = new SSHClient(remoteHost, remoteUser, remotePwd); SSHClientOutput sshOutput; try { sshOutput = ssh.execCommand(command, remoteTimeoutSeconds, logAppender); int exitCode = sshOutput.getExitCode(); String output = sshOutput.getText(); return new Pair<Integer, String>(exitCode, output); } catch (IOException e) { throw e; } catch (Exception e) { throw new IOException(e.getMessage(), e); } }