use of com.jn.agileway.ssh.client.supports.command.executor.SshCommandLineExecutor in project agileway by fangjinuo.
the class SshCommandLineExecutorTest method testExec.
private void testExec(SshConnectionFactory connectionFactory, AbstractSshConnectionConfig connectionConfig) throws SshException, IOException {
// connectionConfig.setHost("192.168.234.128");
connectionConfig.setHost("192.168.1.70");
connectionConfig.setPort(22);
connectionConfig.setUser("fangjinuo");
connectionConfig.setPassword("fjn13570");
SshConnection connection = connectionFactory.get(connectionConfig);
SshCommandLineExecutor executor = new SshCommandLineExecutor(connection);
executor.setWorkingDirectory(new File("~/.java"));
OutputAsStringExecuteStreamHandler output = new OutputAsStringExecuteStreamHandler();
executor.setStreamHandler(output);
executor.execute(CommandLine.parse("ifconfig"));
showResult(executor);
System.out.println("====================================");
executor.execute(CommandLine.parse("ls -al"));
showResult(executor);
connection.close();
}
Aggregations