Blockland Forums > Modification Help
Remote Console Monitoring
<< < (2/2)
Kalphiter:

--- Code: ---    public void run()
    {
String consoleLine = null;
    try
{
    String lastTwoChars = "";
    String lastChar_0 = "";
    String lastChar_1 = "";

    Runtime rt = Runtime.getRuntime();

    proc = rt.exec(cmd);
    proc_in = proc.getInputStream();
    proc_out = proc.getOutputStream();
    proc_err = proc.getErrorStream();
    BufferedReader input = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    output = new BufferedWriter(new OutputStreamWriter(proc.getOutputStream()));
    String currentChar;
    int lineInt;
    while ((lineInt = input.read()) >= 0 && lineInt < 256)
    {
currentChar = new String(new byte[] { new Integer(lineInt).byteValue() });
lastChar_0 = lastChar_1;
lastChar_1 = currentChar;
lastTwoChars = lastChar_0 + lastChar_1;

if(lineInt == 10)
{
    addConsole(consoleLine);
    consoleLine = "";
}
else if(lineInt != 13)
    consoleLine += currentChar;
    }
    running = false;
}
catch(Exception g)
{
    addConsole("Exception: "+ g);
    running = false;
}
running = false;
onStop();
    }
--- End code ---
Of course, there are many methods that aren't there, and I was just having fun with reading character by character
cucumberdude:
Great, thanks.

EDIT: Tried it out with the required modifications - it works beautifully. I didn't think this kind of thing would work (what with the custom console), but hey!
Navigation
Message Index
Previous page

Go to full version