org.shept.util
Class CommandShellExecute

java.lang.Object
  extended by org.shept.util.CommandShellExecute
All Implemented Interfaces:
Runnable

public class CommandShellExecute
extends Object
implements Runnable

This class executes windows command-line jobs and swallows all error and screen I/O that may occur This source is from the internet and slightly modified to use Logging and a local 'StreamGobbler' which swallows command line error and info output

Author:
Andreas Hahn
See Also:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html?page=3

Nested Class Summary
(package private)  class CommandShellExecute.StreamGobbler
          This gobbler swallows any streamed output from the operation and writes it into the log
 
Field Summary
protected  String cmdString
           
protected  String[] envp
           
private  Integer exitVal
           
private  boolean isRunning
           
private static org.apache.commons.logging.Log log
           
protected  File workingDirectory
           
 
Constructor Summary
CommandShellExecute()
           
CommandShellExecute(String cmdString)
           
 
Method Summary
static String[] getEnvironment(String[] addEnv)
          Merge the existing environment with additional parameters If the additional parameters are null then simply return the environment strings
 Integer getExitVal()
           
 boolean isRunning()
           
 void run()
          Run the command shell
 void setCmdString(String cmdString)
           
 void setEnvp(String[] envp)
           
 void setEnvpAdd(String[] envp)
          set additional environment parameters to the ones inherited by the shell
 void setWorkingDirectory(File workingDirectory)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cmdString

protected String cmdString

envp

protected String[] envp

workingDirectory

protected File workingDirectory

isRunning

private boolean isRunning

exitVal

private Integer exitVal

log

private static final org.apache.commons.logging.Log log
Constructor Detail

CommandShellExecute

public CommandShellExecute()

CommandShellExecute

public CommandShellExecute(String cmdString)
Method Detail

getEnvironment

public static String[] getEnvironment(String[] addEnv)
Merge the existing environment with additional parameters If the additional parameters are null then simply return the environment strings

Parameters:
addEnv -
Returns:

run

public void run()
Run the command shell

Specified by:
run in interface Runnable

getExitVal

public Integer getExitVal()
Returns:
the exitVal

setWorkingDirectory

public void setWorkingDirectory(File workingDirectory)
Parameters:
workingDirectory - the workingDirectory to set

setEnvp

public void setEnvp(String[] envp)
Parameters:
envp - the envp to set

setEnvpAdd

public void setEnvpAdd(String[] envp)
set additional environment parameters to the ones inherited by the shell

Parameters:
cmdString -

setCmdString

public void setCmdString(String cmdString)

isRunning

public boolean isRunning()


Copyright © 2011. All Rights Reserved.