public int waitForMux(String[] waitFor, boolean readLineOnMatch) throws IOException { prepare(waitFor); return readFromStream(readLineOnMatch); }
public void run() { try { sleep(timeout); } catch (InterruptedException e) { return; } alive = false; } };
public void connect(String host, int port, String username, String password) throws IOException { connect(host, port, username, password, null); }
public void connect(String host, int port) throws IOException { try { connectionLibrary.connect(host, port); } catch (OperationNotSupportedException e) { throw new RuntimeException(e); } setupStreams(); }
public void sendLine(String text) throws IOException { print(text, true); }
public boolean waitFor(String waitFor) throws IOException { return waitFor(waitFor, false); }
public DefaultStreamConnection() { this.connectionLibrary = new GanymedSSHLibrary(); }
public int waitForMux(String... waitFor) throws IOException { return waitForMux(waitFor, false); }
public void setDebug(boolean debug) { if (debug) { addStreamListener(new StreamListener() { public void hasRead(byte b) { if (b != '\r') System.out.print((char) b); } public void hasWritten(byte[] b) { // Not usually necessary // System.out.print(new String(b)); } public void init(PrintWriter writer) { } }); } }
public void respond(String prompt, String response) { if (response == null) { respondWith.remove(prompt); } else { respondWith.put(prompt, new Response(prompt, response)); } }
protected void prepare(String[] text) { this.alive = true; for (String val : text) { waitFor.add(new Prompt(val)); } this.lastLine.setLength(0); }
public boolean waitFor(String waitFor, boolean readLineOnMatch) throws IOException { prepare(new String[] { waitFor }); return (readFromStream(readLineOnMatch) == 0); }
public void connect(String host, String username, String password) throws IOException { try { connectionLibrary.connect(host, username, password); } catch (OperationNotSupportedException e) { throw new RuntimeException(e); } setupStreams(); }
public void connect(String host, String username) throws IOException { connect(host, SSH_DEFAULT_PORT, username, ""); }
public void send(String text) throws IOException { print(text, false); }
public void connect(String host, int port, String username, final String password) throws IOException { try { connectionLibrary.connect(host, port, username, password); } catch (OperationNotSupportedException e) { throw new RuntimeException(e); } setupStreams(); }
public void connect(String host, String username, String password) throws IOException { connect(host, SSH_DEFAULT_PORT, username, password); }
public void connect(String host, String username) throws IOException { try { connectionLibrary.connect(host, username); } catch (OperationNotSupportedException e) { throw new RuntimeException(e); } setupStreams(); }