Guest User

Untitled

a guest
May 30th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1.  
  2. package tias
  3.  
  4. import org.rev6.scf.*;
  5. import java.io.ByteArrayOutputStream;
  6.  
  7. /**
  8. *
  9. * @author jwhaley
  10. */
  11. public class TestCommand {
  12. public static void main(String[] args) {
  13. String host = "somewhere.com";
  14. String username = "whaley";
  15. String password = "password";
  16.  
  17. SshConnection ssh = null;
  18.  
  19. try
  20. {
  21. ByteArrayOutputStream baos = new ByteArrayOutputStream();
  22. ssh = new SshConnection(host,username,password);
  23. ssh.connect();
  24. ssh.executeTask(new SshCommand("uname -a",baos));
  25. String output = new String(baos.toByteArray());
  26. System.out.println(output);
  27. }
  28. catch (SshException e)
  29. {
  30. e.printStackTrace();
  31. }
  32. finally
  33. {
  34. if (ssh != null)
  35. {
  36. ssh.disconnect();
  37. }
  38.  
  39. }
  40. }
  41. }
Add Comment
Please, Sign In to add comment