it.unimo.dbgroup.momis.tools
Class UnixCommand

java.lang.Object
  extended byit.unimo.dbgroup.momis.tools.UnixCommand

public class UnixCommand
extends java.lang.Object

Execute system commands wrapping results into strings.

Author:
Alberto Corni, Gen 2000

This class contains only static components and has been designed to run on Unix machines (even if porting to Windows architecure will be pretty easy it is enough to change the execution string "/bin/sh -c" whith the appropriate command.)
This class is basically based on the method Runtime.exec();


Field Summary
private static int BUFLEN
          Size of the buffer used to read the output streams
 
Constructor Summary
UnixCommand()
           
 
Method Summary
static int exec(java.lang.String[] param)
          Executes a command and returns the stdOut and stdErr as strings.
static void main(java.lang.String[] args)
          Routine used to test the class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFLEN

private static final int BUFLEN
Size of the buffer used to read the output streams

See Also:
Constant Field Values
Constructor Detail

UnixCommand

public UnixCommand()
Method Detail

main

public static void main(java.lang.String[] args)
Routine used to test the class.


exec

public static int exec(java.lang.String[] param)
Executes a command and returns the stdOut and stdErr as strings.

Parameters:
param - way chosen way to pass strings.
In Java is not easy to pass String by reference. I chose to use an array of pointer to strings, You have to fill the first string with the command and this routine will fill other 2 strings with stdOut and stdErr

0 - in: command String
1 - out: StdOutput of the executed command
2 - out: StdError of the executed command
Returns:
the exit code of the command.


Universita' di Modena e Reggio Emilia