Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package tias
- import org.rev6.scf.*;
- import java.io.ByteArrayOutputStream;
- /**
- *
- * @author jwhaley
- */
- public class TestCommand {
- public static void main(String[] args) {
- String host = "somewhere.com";
- String username = "whaley";
- String password = "password";
- SshConnection ssh = null;
- try
- {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- ssh = new SshConnection(host,username,password);
- ssh.connect();
- ssh.executeTask(new SshCommand("uname -a",baos));
- String output = new String(baos.toByteArray());
- System.out.println(output);
- }
- catch (SshException e)
- {
- e.printStackTrace();
- }
- finally
- {
- if (ssh != null)
- {
- ssh.disconnect();
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment