Package com.xebialabs.overthere

Examples of com.xebialabs.overthere.OverthereConnection


    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      connection.execute(CmdLine.build("cp", "/etc/motd", "/tmp/motd1"));
      OverthereFile motd1 = connection.getFile("/tmp/motd1");
      OverthereFile motd2 = connection.getFile("/tmp/motd2");
      motd2.delete();

      System.err.println("Exists #1: " + motd1.exists());
      System.err.println("Exists #2: " + motd2.exists());

      motd1.renameTo(motd2);
      System.err.println("Exists #1: " + motd1.exists());
      System.err.println("Exists #2: " + motd2.exists());

      motd2.copyTo(motd1);
      System.err.println("Exists #1: " + motd1.exists());
      System.err.println("Exists #2: " + motd2.exists());

      motd1.delete();
      motd2.delete();
      System.err.println("Exists #1: " + motd1.exists());
      System.err.println("Exists #2: " + motd2.exists());
    } finally {
      connection.close();
    }
  }
View Full Code Here


    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      OverthereFile motd = connection.getFile("/etc/motd");
      BufferedReader r = new BufferedReader(new InputStreamReader(motd.getInputStream()));
      try {
        String line;
        while((line = r.readLine()) != null) {
          System.err.println(line);
        }
      } finally {
        r.close();
      }
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(ADDRESS, "windows-box");
    options.set(USERNAME, "Administrator");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, WINDOWS);
    options.set(CONNECTION_TYPE, TELNET);
    OverthereConnection connection = Overthere.getConnection("cifs", options);

    try {
      connection.execute(CmdLine.build("type", "\\windows\\system32\\drivers\\etc\\hosts"));
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      connection.execute(CmdLine.build("cat", "/etc/motd"));
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);

    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      OverthereProcess process = connection.startProcess(CmdLine.build("cat", "/etc/motd"));
      BufferedReader stdout = new BufferedReader(new InputStreamReader(process.getStdout()));
      try {
        String line;
        while((line = stdout.readLine()) != null) {
          System.err.println(line);
        }
      } finally {
        stdout.close();
      }
      int exitCode = process.waitFor();
      System.err.println("Exit code: " + exitCode);
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      OverthereFile motd = connection.getFile("/etc/motd");
      System.out.println("Length        : " + motd.length());
      System.out.println("Last modified : " + motd.lastModified());
      System.out.println("Exists        : " + motd.exists());
      System.out.println("Can read      : " + motd.canRead());
      System.out.println("Can write     : " + motd.canWrite());
      System.out.println("Can execute   : " + motd.canExecute());
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SFTP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      connection.execute(CmdLine.build("cp", "-r", "/var/log/apt", "/tmp/logs1"));
      OverthereFile logs1 = connection.getFile("/tmp/logs1");
      OverthereFile logs2 = connection.getFile("/tmp/logs2");
      logs2.delete();

      System.err.println("Exists #1: " + logs1.exists());
      System.err.println("Exists #2: " + logs2.exists());

      logs1.renameTo(logs2);
      System.err.println("Exists #1: " + logs1.exists());
      System.err.println("Exists #2: " + logs2.exists());

      logs2.copyTo(logs1);
      System.err.println("Exists #1: " + logs1.exists());
      System.err.println("Exists #2: " + logs2.exists());

      logs1.deleteRecursively();
      logs2.deleteRecursively();
      System.err.println("Exists #1: " + logs1.exists());
      System.err.println("Exists #2: " + logs2.exists());
    } finally {
      connection.close();
    }
  }
View Full Code Here

    options.set(ADDRESS, "unix-box");
    options.set(USERNAME, "demo");
    options.set(PASSWORD, "secret");
    options.set(OPERATING_SYSTEM, UNIX);
    options.set(CONNECTION_TYPE, SCP);
    OverthereConnection connection = Overthere.getConnection("ssh", options);
    try {
      OverthereFile motd = connection.getFile("/tmp/new-motd");
      PrintWriter w = new PrintWriter(motd.getOutputStream());
      try {
        w.println("An Overthere a day keeps the doctor away");
        w.println("Written on " + new java.util.Date() + " from " + InetAddress.getLocalHost() + " running " + System.getProperty("os.name") + " " + System.getProperty("os.version"));
      } finally {
        w.close();
      }
      connection.execute(CmdLine.build("cat", "/tmp/new-motd"));
    } finally {
      connection.close();
    }
  }
View Full Code Here

TOP

Related Classes of com.xebialabs.overthere.OverthereConnection

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.