Browse Prior Art Database

Capture Java process stdout to manipulate system properties

IP.com Disclosure Number: IPCOM000013336D
Original Publication Date: 2000-Sep-01
Included in the Prior Art Database: 2003-Jun-18
Document File: 2 page(s) / 55K

Publishing Venue

IBM

Abstract

A program is disclosed that demonstrates a way to capture a JAVA* processes, send it to standard output, and manipulate system characteristics or programs such as tty, xterms, fonts, system config, memory, etc.

This text was extracted from a PDF file.
This is the abbreviated version, containing approximately 97% of the total text.

Page 1 of 2

Capture Java process stdout to manipulate system properties

A program is disclosed that demonstrates a way to capture a JAVA* processes, send it to standard output, and manipulate system characteristics or programs such as tty, xterms, fonts, system config, memory, etc.

The actual program also shows actual executable output in immediate readable form. This solution uses the Java String, BufferedReader, System and InputStreamReader Classes to capture output from a Java Process and send it to the system standard output.

The following program serves as an example: import java.io.*;
import java.lang.*;

public class test { public static void main (String args[]) { String a = new String(""); String tmpExecScript = "/bin/sh -c /tmp/12345"; //A simple executable in /tmp called 12345. The 12345 script may contain commands to change certain system settings or programs including display, tty, user permission
settings, etc.

Runtime runtime = Runtime.getRuntime();

try {

Process p = runtime.exec(tmpExecScript); //Create a process which executes

/tmp/12345

BufferedReader in = new BufferedReader(new InputStreamReader(p.getInputStream()),5000);

while ( (a = in.readLine()) != null)

{

System.out.println(a); // Prints all standard output to display

}

p.waitFor();

in.close();

System.out.println("Process exitvalue is " + p.exitValue());

}

catch (IOException e)

{

System.err.println("Test: " + e);

}

catch (java.lang.InterruptedException ie)

{

System.err.println("OS: " + ie);

}

}

} * Trad...