Autopsy  3.1
Graphical digital forensics platform for The Sleuth Kit and other tools.
Classes | Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
org.sleuthkit.autopsy.coreutils.ExecUtil Class Reference

Classes

interface  ProcessTerminator
 
class  StreamToStringRedirect
 
class  StreamToWriterRedirect
 
class  TimedProcessTerminator
 

Public Member Functions

synchronized String execute (final String aCommand, final String...params) throws IOException, InterruptedException
 
synchronized void execute (final Writer stdoutWriter, final String aCommand, final String...params) throws IOException, InterruptedException
 
synchronized void stop ()
 
synchronized int getExitValue ()
 

Static Public Member Functions

static int execute (ProcessBuilder processBuilder) throws SecurityException, IOException
 
static int execute (ProcessBuilder processBuilder, ProcessTerminator terminator) throws SecurityException, IOException
 
static int execute (ProcessBuilder processBuilder, long timeOut, TimeUnit units, ProcessTerminator terminator) throws SecurityException, IOException
 
static void killProcess (Process process)
 

Private Attributes

Process proc = null
 
ExecUtil.StreamToStringRedirect errorStringRedirect = null
 
ExecUtil.StreamToStringRedirect outputStringRedirect = null
 
ExecUtil.StreamToWriterRedirect outputWriterRedirect = null
 
int exitValue = -100
 

Static Private Attributes

static final long DEFAULT_TIMEOUT = 5
 
static final TimeUnit DEFAULT_TIMEOUT_UNITS = TimeUnit.SECONDS
 
static final Logger logger = Logger.getLogger(ExecUtil.class.getName())
 

Detailed Description

Executes a command line using an operating system process with a configurable timeout and pluggable logic to kill or continue the process on timeout.

Definition at line 36 of file ExecUtil.java.

Member Function Documentation

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder) throws SecurityException, IOException
static

Runs a process without a timeout and terminator.

Parameters
processBuilderA process builder used to configure and construct the process to be run.
Returns
the exit value of the process
Exceptions
SecurityExceptionif a security manager exists and vetoes any aspect of running the process.
IOExceptionif an I/O error occurs.

Definition at line 97 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute(), and org.sleuthkit.autopsy.examples.SampleExecutableDataSourceIngestModule.process().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder,
ProcessTerminator  terminator 
) throws SecurityException, IOException
static

Runs a process using the default timeout and a custom terminator.

Parameters
processBuilderA process builder used to configure and construct the process to be run.
terminatorThe terminator.
Returns
the exit value of the process
Exceptions
SecurityExceptionif a security manager exists and vetoes any aspect of running the process.
IOExceptionif an I/O error occurs.

Definition at line 120 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TIMEOUT, org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TIMEOUT_UNITS, and org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

static int org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( ProcessBuilder  processBuilder,
long  timeOut,
TimeUnit  units,
ProcessTerminator  terminator 
) throws SecurityException, IOException
static

Runs a process using a custom terminator.

Parameters
processBuilderA process builder used to configure and construct the process to be run.
timeOutThe duration of the timeout.
unitsThe units for the timeout.
terminatorThe terminator.
Returns
the exit value of the process
Exceptions
SecurityExceptionif a security manager exists and vetoes any aspect of running the process.
IOExceptionif an I/o error occurs.

Definition at line 137 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.Logger.getLogger(), and org.sleuthkit.autopsy.coreutils.ExecUtil.killProcess().

synchronized String org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( final String  aCommand,
final String...  params 
) throws IOException, InterruptedException

Execute a process. Redirect asynchronously stdout to a string and stderr to nowhere. Use only for small outputs, otherwise use the execute() variant with Writer.

Parameters
aCommandcommand to be executed
paramsparameters of the command
Returns
string buffer with captured stdout

Definition at line 203 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect, and org.sleuthkit.autopsy.coreutils.ExecUtil.outputStringRedirect.

synchronized void org.sleuthkit.autopsy.coreutils.ExecUtil.execute ( final Writer  stdoutWriter,
final String  aCommand,
final String...  params 
) throws IOException, InterruptedException

Execute a process. Redirect asynchronously stdout to a passed in writer and stderr to nowhere.

Parameters
stdoutWriterfile writer to write stdout to
aCommandcommand to be executed
paramsparameters of the command
Returns
string buffer with captured stdout

Definition at line 249 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect, and org.sleuthkit.autopsy.coreutils.ExecUtil.outputWriterRedirect.

synchronized int org.sleuthkit.autopsy.coreutils.ExecUtil.getExitValue ( )

Gets the exit value returned by the subprocess used to execute a command.

Returns
The exit value or the distinguished value -100 if this method is called before the exit value is set.

Definition at line 322 of file ExecUtil.java.

References org.sleuthkit.autopsy.coreutils.ExecUtil.exitValue.

static void org.sleuthkit.autopsy.coreutils.ExecUtil.killProcess ( Process  process)
static
synchronized void org.sleuthkit.autopsy.coreutils.ExecUtil.stop ( )

Member Data Documentation

final long org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TIMEOUT = 5
staticprivate

Definition at line 38 of file ExecUtil.java.

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

final TimeUnit org.sleuthkit.autopsy.coreutils.ExecUtil.DEFAULT_TIMEOUT_UNITS = TimeUnit.SECONDS
staticprivate

Definition at line 39 of file ExecUtil.java.

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.execute().

ExecUtil.StreamToStringRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.errorStringRedirect = null
private
int org.sleuthkit.autopsy.coreutils.ExecUtil.exitValue = -100
private
final Logger org.sleuthkit.autopsy.coreutils.ExecUtil.logger = Logger.getLogger(ExecUtil.class.getName())
staticprivate

EVERYTHING FOLLOWING THIS LINE IS DEPRECATED AND SLATED FOR REMOVAL

Definition at line 186 of file ExecUtil.java.

Referenced by org.sleuthkit.autopsy.coreutils.ExecUtil.killProcess().

ExecUtil.StreamToStringRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.outputStringRedirect = null
private
ExecUtil.StreamToWriterRedirect org.sleuthkit.autopsy.coreutils.ExecUtil.outputWriterRedirect = null
private
Process org.sleuthkit.autopsy.coreutils.ExecUtil.proc = null
private

Definition at line 187 of file ExecUtil.java.


The documentation for this class was generated from the following file:

Copyright © 2012-2015 Basis Technology. Generated on: Mon Oct 19 2015
This work is licensed under a Creative Commons Attribution-Share Alike 3.0 United States License.