ariba.util.io
Class Exec

java.lang.Object
  extended by ariba.util.io.Exec

public final class Exec
extends Object

Runtime.exec made simple


Method Summary
static int exec(String[] cmdarray, String[] envp, int timeout, InputStream stdin, OutputStream stdout, OutputStream stderr)
           
static int execWithMasterPassword(String[] cmdarray, String[] envp, int timeout, OutputStream stdout, OutputStream stderr)
          Exec the given command adding the master password info if necessary.
static void main(String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

exec

public static int exec(String[] cmdarray,
                       String[] envp,
                       int timeout,
                       InputStream stdin,
                       OutputStream stdout,
                       OutputStream stderr)
                throws IOException
Throws:
IOException

execWithMasterPassword

public static int execWithMasterPassword(String[] cmdarray,
                                         String[] envp,
                                         int timeout,
                                         OutputStream stdout,
                                         OutputStream stderr)
                                  throws IOException
Exec the given command adding the master password info if necessary. Specifically, the -masterPasswordNoPrompt option is appended to the cmdarray array, and the master password is fetched and passed to the stdin of the exec call.

Two limitations:

(1) Original command that requres input data is not supported. In fact, there is no provision for the caller to provide the stdin (2) The -masterPasswordNoPrompt is appended at the end of the command line array, so commands that pipe or redirect output such as {"tableedit", "-script", "scriptfile", ">", "outfile"} will become {"tableedit", "-script", "scriptfile", ">", "outfile", "-masterPasswordNoPrompt"), which clearly won't work.

Parameters:
cmdarray - the command to execute, must be non null and not empty
envp - the environment to execute, can be mull.
timeout - timeout, a value of timeout will timeout immediately, negative value means no timeout (wait forever)
stdout - the stdout
stderr - the stderr
Returns:
the status of the exec'ed process. A value of 0 indicates normal termination.
Throws:
IOException - if an I/O error occurs

main

public static void main(String[] args)


AribaWeb User Interface Development Framework
Copyright © 2000-2009 Ariba, Inc. All Rights Reserved.