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 int waitForMux(String[] waitFor, boolean readLineOnMatch) throws IOException { prepare(waitFor); return readFromStream(readLineOnMatch); }
final StreamConnection conn = new DefaultStreamConnection();
break outer; int match = lookForMatch(c); if (match != -1) { result = match; lookForResponse((char) data[x]); lastChar = (char) data[x]; reset(); return result;
public void sendLine(String text) throws IOException { print(text, true); }
private void print(String text, boolean eol) throws IOException { text = text.replace("^C", String.valueOf((char) 3)); text = text.replace("^M", endOfLine); if (eol) { out.print(text+endOfLine); out.flush(); getLine(); } else { out.print(text); out.flush(); } byte[] bytes = text.getBytes(); for (StreamListener listener : streamListeners) { listener.hasWritten(bytes); } }
public static void main(String[] args) throws IOException { ScriptRecorder rec = new PythonScriptRecorder(); args = rec.processForLearningMode(args); String filePath = args[0]; PythonInterpreter interp = new PythonInterpreter(); StreamConnection conn = new DefaultStreamConnection(); // deprecated interp.set("ssh", conn); interp.set("conn", conn); interp.set("args", args); interp.execfile(filePath); }
public void send(String text) throws IOException { print(text, false); }
setPromptSize(((Integer) parser.getOptionValue(optPromptSize, Integer.valueOf(10))).intValue()); StreamConnection streamConnection = new DefaultStreamConnection(); streamConnection.addStreamListener(this); streamConnection.connect(host, port, username, password);
public boolean waitFor(String waitFor, boolean readLineOnMatch) throws IOException { prepare(new String[] { waitFor }); return (readFromStream(readLineOnMatch) == 0); }
void lookForResponse(char s) throws IOException { for (Response response : respondWith.values()) { if (response.matchChar(s)) { if (response.match()) { print(response.getResponse(), false); response.resetPos(); } else { response.nextPos(); } } else { response.resetPos(); } } }