=>> From: Juan Carlos [mailto:[EMAIL PROTECTED]]
=>>
=>> ¿How to execute an linux command, to obtain any
=>> information, using Java? (ex: the CAT command).
=>> I have Red Hat version 5.3, and jdk1.1.5.
I suspect you're asking:
In a Java program, how do I execute an external program and read its
results from an InputStream?
I'm using 1.2, and you can do it like this:
import java.lang.*;
import java.util.*;
import java.security.*;
import java.io.*;
class foo {
public static void main( String [] argv )
throws IOException
{
Process p = Runtime.getRuntime( ).exec(
"/bin/date" );
InputStream i = p.getInputStream( );
int ch;
while ((ch = i.read( )) != -1) {
System.out.println( "Got '" +
new
Character((char)ch).toString( ) +
"'" );
}
System.out.println( "Done!" );
}
}
d.
----------------------------------------------------------------------
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]